gf/database/gredis/gredis_z_unit_config_test.go
2021-11-13 23:23:55 +08:00

37 lines
918 B
Go

// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package gredis_test
import (
"testing"
"time"
"github.com/gogf/gf/v2/database/gredis"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/test/gtest"
)
func Test_ConfigFromMap(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
c, err := gredis.ConfigFromMap(g.Map{
`address`: `127.0.0.1:6379`,
`db`: `10`,
`pass`: `&*^%$#65Gv`,
`minIdle`: `10`,
`MaxIdle`: `100`,
`ReadTimeout`: `10s`,
})
t.AssertNil(err)
t.Assert(c.Address, `127.0.0.1:6379`)
t.Assert(c.Db, `10`)
t.Assert(c.Pass, `&*^%$#65Gv`)
t.Assert(c.MinIdle, 10)
t.Assert(c.MaxIdle, 100)
t.Assert(c.ReadTimeout, 10*time.Second)
})
}