Skip to content

Commit

Permalink
file: fix legacy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
unknwon committed Nov 12, 2021
1 parent 1c1c7ac commit c2f10d6
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions file_test.go
Expand Up @@ -266,30 +266,29 @@ VERSION = v1`))
assert.Equal(t, "v1", f.Section("").Key("version").String())
})

Convey("Get section after deletion", t, func() {
f, err := ini.Load([]byte(`
t.Run("get sections after deletion", func(t *testing.T) {
f, err := Load([]byte(`
[RANDOM]
`))
So(f, ShouldNotBeNil)
So(err, ShouldBeNil)
require.NoError(t, err)
require.NotNil(t, f)

sectionNames := f.SectionStrings()
sort.Strings(sectionNames)
So(sectionNames, ShouldResemble, []string{ini.DefaultSection, "RANDOM"})
assert.Equal(t, []string{DefaultSection, "RANDOM"}, sectionNames)

for _, currentSection := range sectionNames {
f.DeleteSection(currentSection)
}
Convey("Section recreated", func() {
for sectionParam, expectedSectionName := range map[string]string{
"": ini.DefaultSection,
"RANDOM": "RANDOM",
} {
sec := f.Section(sectionParam)
So(sec, ShouldNotBeNil)
So(sec.Name(), ShouldEqual, expectedSectionName)
}
})

for sectionParam, expectedSectionName := range map[string]string{
"": DefaultSection,
"RANDOM": "RANDOM",
} {
sec := f.Section(sectionParam)
require.NotNil(t, sec)
assert.Equal(t, expectedSectionName, sec.Name())
}
})

}
Expand Down

0 comments on commit c2f10d6

Please sign in to comment.