config/load_test.go
Lunny Xiao ba2829cb17
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Add LoadIfExist (#1)
2019-10-29 05:08:14 +00:00

22 lines
349 B
Go

package config
import (
"os"
"testing"
)
func TestLoad(t *testing.T) {
os.Setenv("dbhost", "localhost")
cfgs, err := LoadIfExist("./test_cfg.ini")
if err != nil {
t.Error(err)
}
if cfgs.Has("no_exist_key") {
t.Errorf("no exist key error")
}
if cfgs.Get("dbhost") != "localhost" {
t.Errorf("dbhost should be override by envs")
}
}