go17/book/config/load_test.go

20 lines
432 B
Go
Raw Permalink Normal View History

2024-11-16 17:22:21 +08:00
package config_test
import (
"testing"
"gitlab.com/go-course-project/go17/book/config"
)
// LoadConfigFromYaml
2024-11-16 17:53:04 +08:00
// go test 它自动帮你写来一个main函数然后把测试逻辑装进去, 然后编译允许
2024-11-16 17:22:21 +08:00
func TestLoadConfigFromYaml(t *testing.T) {
if err := config.LoadConfigFromYaml("application.yaml"); err != nil {
// 报错测试失败,并且结束
t.Fatal(err)
}
// 加载成功
t.Log(config.Get())
}