From ac6108a87d0b95bf23207079b5203afe0006aee7 Mon Sep 17 00:00:00 2001 From: astaxie Date: Mon, 11 Nov 2013 21:25:03 +0800 Subject: [PATCH] add more json test info --- config/json_test.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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") + } + } }