feat(conf): add conf single test
This commit is contained in:
parent
b182d7602d
commit
4d9558c21f
|
@ -1,6 +1,7 @@
|
||||||
package conf
|
package conf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
@ -8,6 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestConf(t *testing.T) {
|
func TestConf(t *testing.T) {
|
||||||
|
|
||||||
// 外部导入 conf.yaml 需要导入 conf 包
|
// 外部导入 conf.yaml 需要导入 conf 包
|
||||||
// 每次迁移文件时, 使用 sudo make init-conf来将yam文件迁移到指定的文件夹下
|
// 每次迁移文件时, 使用 sudo make init-conf来将yam文件迁移到指定的文件夹下
|
||||||
// get 使用, 读取 public_conf 配置文件
|
// get 使用, 读取 public_conf 配置文件
|
||||||
|
@ -22,3 +24,20 @@ func TestConf(t *testing.T) {
|
||||||
host := viper.GetString("host")
|
host := viper.GetString("host")
|
||||||
require.Equal(t, host, "1222")
|
require.Equal(t, host, "1222")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMiddleConf(t *testing.T) {
|
||||||
|
ct := viper.GetStringMap("plugins-control")
|
||||||
|
|
||||||
|
fmt.Println(ct)
|
||||||
|
|
||||||
|
d := viper.GetInt("middleware-driver.driverCount")
|
||||||
|
require.Equal(t, d, 1000)
|
||||||
|
c := viper.GetInt("middleware-driver.middleConsumerCount")
|
||||||
|
require.Equal(t, c, 5)
|
||||||
|
|
||||||
|
p := viper.GetStringMap("plugins-control")
|
||||||
|
for key, val := range p {
|
||||||
|
fmt.Println(key, val)
|
||||||
|
}
|
||||||
|
// fmt.Println(p)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue