file: fix legacy tests

This commit is contained in:
Joe Chen
2021-11-12 21:50:40 +08:00
parent 1c1c7acc1c
commit c2f10d6ccf
+10 -11
View File
@@ -266,32 +266,31 @@ VERSION = v1`))
assert.Equal(t, "v1", f.Section("").Key("version").String()) assert.Equal(t, "v1", f.Section("").Key("version").String())
}) })
Convey("Get section after deletion", t, func() { t.Run("get sections after deletion", func(t *testing.T) {
f, err := ini.Load([]byte(` f, err := Load([]byte(`
[RANDOM] [RANDOM]
`)) `))
So(f, ShouldNotBeNil) require.NoError(t, err)
So(err, ShouldBeNil) require.NotNil(t, f)
sectionNames := f.SectionStrings() sectionNames := f.SectionStrings()
sort.Strings(sectionNames) sort.Strings(sectionNames)
So(sectionNames, ShouldResemble, []string{ini.DefaultSection, "RANDOM"}) assert.Equal(t, []string{DefaultSection, "RANDOM"}, sectionNames)
for _, currentSection := range sectionNames { for _, currentSection := range sectionNames {
f.DeleteSection(currentSection) f.DeleteSection(currentSection)
} }
Convey("Section recreated", func() {
for sectionParam, expectedSectionName := range map[string]string{ for sectionParam, expectedSectionName := range map[string]string{
"": ini.DefaultSection, "": DefaultSection,
"RANDOM": "RANDOM", "RANDOM": "RANDOM",
} { } {
sec := f.Section(sectionParam) sec := f.Section(sectionParam)
So(sec, ShouldNotBeNil) require.NotNil(t, sec)
So(sec.Name(), ShouldEqual, expectedSectionName) assert.Equal(t, expectedSectionName, sec.Name())
} }
}) })
})
} }
func TestFile_Sections(t *testing.T) { func TestFile_Sections(t *testing.T) {