1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-11 15:20:38 +00:00

added tests config/json_test that test missing key usecases. created a template function to fetch AppConfig values

This commit is contained in:
Michael
2014-05-30 23:48:23 -05:00
parent 61008fe75c
commit a673a85d4a
3 changed files with 62 additions and 0 deletions

View File

@ -100,4 +100,28 @@ func TestJson(t *testing.T) {
t.Fatal("get host err")
}
}
if _, err := jsonconf.Int("unknown"); err == nil {
t.Error("unknown keys should return an error when expecting an Int")
}
if _, err := jsonconf.Int64("unknown"); err == nil {
t.Error("unknown keys should return an error when expecting an Int64")
}
if _, err := jsonconf.Float("unknown"); err == nil {
t.Error("unknown keys should return an error when expecting a Float")
}
if _, err := jsonconf.DIY("unknown"); err == nil {
t.Error("unknown keys should return an error when expecting an interface{}")
}
if val := jsonconf.String("unknown"); val != "" {
t.Error("unknown keys should return an empty string when expecting a String")
}
if _, err := jsonconf.Bool("unknown"); err == nil {
t.Error("unknown keys should return an error when expecting a Bool")
}
}