1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
This commit is contained in:
2023-12-13 17:08:56 +08:00
parent 330d9f78d3
commit bb979f5ccb
5 changed files with 289 additions and 0 deletions

View 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))
}