1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-07 02:50:19 +00:00
This commit is contained in:
ysqi
2016-01-23 14:53:52 +08:00
parent af346e871b
commit 51ae45a799
2 changed files with 83 additions and 9 deletions

View File

@ -15,6 +15,7 @@
package config
import (
"io/ioutil"
"os"
"testing"
)
@ -101,3 +102,54 @@ func TestIni(t *testing.T) {
}
}
func TestIniSave(t *testing.T) {
const (
inicontext = `
app = app
;comment one
#comment two
# comment three
appname = beeapi
httpport = 8080
# DB Info
# enable db
[dbinfo]
# db type name
# suport mysql,sqlserver
name = mysql
`
saveResult = `app=app
#comment one
#comment two
# comment three
appname=beeapi
httpport=8080
# DB Info
# enable db
[dbinfo]
# db type name
# suport mysql,sqlserver
name=mysql
`
)
cfg, err := NewConfigData("ini", []byte(inicontext))
if err != nil {
t.Fatal(err)
}
name := "newIniConfig.ini"
if err := cfg.SaveConfigFile(name); err != nil {
t.Fatal(err)
}
defer os.Remove(name)
if data, err := ioutil.ReadFile(name); err != nil {
t.Fatal(err)
} else if string(data) != saveResult {
t.Fatal("different after save ini config file.")
}
}