ini_test: add test case for #198

This commit is contained in:
unknwon
2019-08-06 00:00:55 -07:00
parent dd2c58e130
commit e145131f9c
+27 -4
View File
@@ -266,6 +266,19 @@ e-mail = u@gogs.io
So(f.Section("Author").Key("e-mail").String(), ShouldBeEmpty)
})
})
// Ref: https://github.com/go-ini/ini/issues/198
Convey("Insensitive load with default section", t, func() {
f, err := ini.InsensitiveLoad([]byte(`
user = unknwon
[profile]
email = unknwon@local
`))
So(err, ShouldBeNil)
So(f, ShouldNotBeNil)
So(f.Section(ini.DefaultSection).Key("user").String(), ShouldEqual, "unknwon")
})
}
func TestLoadSources(t *testing.T) {
@@ -822,18 +835,26 @@ GITHUB = U;n;k;n;w;o;n
Convey("with false `AllowPythonMultilineValues`", func() {
Convey("Ignore nonexistent files", func() {
f, err := ini.LoadSources(ini.LoadOptions{AllowPythonMultilineValues: false, Loose: true}, notFoundConf, minimalConf)
f, err := ini.LoadSources(ini.LoadOptions{
AllowPythonMultilineValues: false,
Loose: true,
}, notFoundConf, minimalConf)
So(err, ShouldBeNil)
So(f, ShouldNotBeNil)
Convey("Inverse case", func() {
_, err = ini.LoadSources(ini.LoadOptions{AllowPythonMultilineValues: false}, notFoundConf)
_, err = ini.LoadSources(ini.LoadOptions{
AllowPythonMultilineValues: false,
}, notFoundConf)
So(err, ShouldNotBeNil)
})
})
Convey("Insensitive to section and key names", func() {
f, err := ini.LoadSources(ini.LoadOptions{AllowPythonMultilineValues: false, Insensitive: true}, minimalConf)
f, err := ini.LoadSources(ini.LoadOptions{
AllowPythonMultilineValues: false,
Insensitive: true,
}, minimalConf)
So(err, ShouldBeNil)
So(f, ShouldNotBeNil)
@@ -850,7 +871,9 @@ e-mail = u@gogs.io
})
Convey("Inverse case", func() {
f, err := ini.LoadSources(ini.LoadOptions{AllowPythonMultilineValues: false}, minimalConf)
f, err := ini.LoadSources(ini.LoadOptions{
AllowPythonMultilineValues: false,
}, minimalConf)
So(err, ShouldBeNil)
So(f, ShouldNotBeNil)