mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 00:22:41 +08:00
config
This commit is contained in:
42
configure/configure_test.go
Normal file
42
configure/configure_test.go
Normal file
@ -0,0 +1,42 @@
|
||||
package configure_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/charlienet/go-mixed/configure"
|
||||
"github.com/charlienet/go-mixed/json"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestLoadSpecifiedFile(t *testing.T) {
|
||||
conf, err := configure.New().SetConfigFile("config.toml").Read()
|
||||
t.Log(err)
|
||||
|
||||
assert.Equal(t, "192.168.2.121", conf.GetString("nacos.address", ""))
|
||||
_ = conf
|
||||
}
|
||||
|
||||
func TestNewConfigure(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestNacos(t *testing.T) {
|
||||
conf, err := configure.
|
||||
New().
|
||||
AddConfigPath(".").
|
||||
WithNacos().
|
||||
Read()
|
||||
|
||||
assert.Nil(t, err)
|
||||
|
||||
t.Log(conf.GetString("nacos.address", ""))
|
||||
|
||||
type redis struct {
|
||||
Addrs string
|
||||
}
|
||||
|
||||
r := &redis{}
|
||||
|
||||
t.Log(conf.Load("redis", r))
|
||||
t.Log(json.StructToJsonIndent(r))
|
||||
}
|
Reference in New Issue
Block a user