add more json test info
Showing
1 changed file
with
17 additions
and
1 deletions
| ... | @@ -12,7 +12,14 @@ var jsoncontext = `{ | ... | @@ -12,7 +12,14 @@ var jsoncontext = `{ |
| 12 | "PI": 3.1415976, | 12 | "PI": 3.1415976, |
| 13 | "runmode": "dev", | 13 | "runmode": "dev", |
| 14 | "autorender": false, | 14 | "autorender": false, |
| 15 | "copyrequestbody": true | 15 | "copyrequestbody": true, |
| 16 | "database": { | ||
| 17 | "host": "host", | ||
| 18 | "port": "port", | ||
| 19 | "database": "database", | ||
| 20 | "username": "username", | ||
| 21 | "password": "password" | ||
| 22 | } | ||
| 16 | }` | 23 | }` |
| 17 | 24 | ||
| 18 | func TestJson(t *testing.T) { | 25 | func TestJson(t *testing.T) { |
| ... | @@ -63,4 +70,13 @@ func TestJson(t *testing.T) { | ... | @@ -63,4 +70,13 @@ func TestJson(t *testing.T) { |
| 63 | if jsonconf.String("name") != "astaxie" { | 70 | if jsonconf.String("name") != "astaxie" { |
| 64 | t.Fatal("get name error") | 71 | t.Fatal("get name error") |
| 65 | } | 72 | } |
| 73 | if db, err := jsonconf.DIY("database"); err != nil { | ||
| 74 | t.Fatal(err) | ||
| 75 | } else if m, ok := db.(map[string]interface{}); !ok { | ||
| 76 | t.Fatal("db not map[string]interface{}") | ||
| 77 | } else { | ||
| 78 | if m["host"].(string) != "host" { | ||
| 79 | t.Fatal("get host err") | ||
| 80 | } | ||
| 81 | } | ||
| 66 | } | 82 | } | ... | ... |
-
Please register or sign in to post a comment