@@ -18,6 +18,7 @@ import (
18
18
"bytes"
19
19
"io/ioutil"
20
20
"runtime"
21
+ "sort"
21
22
"testing"
22
23
23
24
"github.com/stretchr/testify/assert"
@@ -264,6 +265,33 @@ VERSION = v1`))
264
265
assert .Equal (t , "ini" , f .Section ("" ).Key ("name" ).String ())
265
266
assert .Equal (t , "v1" , f .Section ("" ).Key ("version" ).String ())
266
267
})
268
+
269
+ Convey ("Get section after deletion" , t , func () {
270
+ f , err := ini .Load ([]byte (`
271
+ [RANDOM]
272
+ ` ))
273
+ So (f , ShouldNotBeNil )
274
+ So (err , ShouldBeNil )
275
+ sectionNames := f .SectionStrings ()
276
+ sort .Strings (sectionNames )
277
+ So (sectionNames , ShouldResemble , []string {ini .DefaultSection , "RANDOM" })
278
+
279
+ for _ , currentSection := range sectionNames {
280
+ f .DeleteSection (currentSection )
281
+ }
282
+ Convey ("Section recreated" , func () {
283
+ for sectionParam , expectedSectionName := range map [string ]string {
284
+ "" : ini .DefaultSection ,
285
+ "RANDOM" : "RANDOM" ,
286
+ } {
287
+ sec := f .Section (sectionParam )
288
+ So (sec , ShouldNotBeNil )
289
+ So (sec .Name (), ShouldEqual , expectedSectionName )
290
+ }
291
+ })
292
+
293
+ })
294
+
267
295
}
268
296
269
297
func TestFile_Sections (t * testing.T ) {
0 commit comments