diff --git a/config/json_test.go b/config/json_test.go index 6e207585..4d3b760f 100644 --- a/config/json_test.go +++ b/config/json_test.go @@ -12,7 +12,14 @@ var jsoncontext = `{ "PI": 3.1415976, "runmode": "dev", "autorender": false, -"copyrequestbody": true +"copyrequestbody": true, +"database": { + "host": "host", + "port": "port", + "database": "database", + "username": "username", + "password": "password" + } }` func TestJson(t *testing.T) { @@ -63,4 +70,13 @@ func TestJson(t *testing.T) { if jsonconf.String("name") != "astaxie" { t.Fatal("get name error") } + if db, err := jsonconf.DIY("database"); err != nil { + t.Fatal(err) + } else if m, ok := db.(map[string]interface{}); !ok { + t.Fatal("db not map[string]interface{}") + } else { + if m["host"].(string) != "host" { + t.Fatal("get host err") + } + } }