mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 00:22:41 +08:00
43 lines
718 B
Go
43 lines
718 B
Go
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))
|
|
}
|