1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-06 12:30:19 +00:00

beego config module json support get data like key:🔑:key

This commit is contained in:
astaxie
2013-12-10 18:09:58 +08:00
parent 34ba7a8e6c
commit 3a0b2e3b95
2 changed files with 98 additions and 20 deletions

View File

@ -18,7 +18,12 @@ var jsoncontext = `{
"port": "port",
"database": "database",
"username": "username",
"password": "password"
"password": "password",
"conns":{
"maxconnection":12,
"autoconnect":true,
"connectioninfo":"info"
}
}
}`
@ -70,9 +75,19 @@ func TestJson(t *testing.T) {
if jsonconf.String("name") != "astaxie" {
t.Fatal("get name error")
}
if jsonconf.String("database::host") != "host" {
t.Fatal("get database::host error")
}
if jsonconf.String("database::conns::connectioninfo") != "info" {
t.Fatal("get database::conns::connectioninfo error")
}
if maxconnection, err := jsonconf.Int("database::conns::maxconnection"); err != nil || maxconnection != 12 {
t.Fatal("get database::conns::maxconnection error")
}
if db, err := jsonconf.DIY("database"); err != nil {
t.Fatal(err)
} else if m, ok := db.(map[string]interface{}); !ok {
t.Log(db)
t.Fatal("db not map[string]interface{}")
} else {
if m["host"].(string) != "host" {