Skip to content

Commit 14e9811

Browse files
authored
test: rename package to be same as the main (#304)
1 parent fd697c7 commit 14e9811

9 files changed

+238
-262
lines changed

.github/workflows/go.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
uses: actions/checkout@v2
2626
- name: Init Go Modules
2727
run: |
28-
go mod init gopkg.in/ini.v1
28+
go mod init github.com/go-ini/ini
2929
go mod tidy
3030
- name: Run golangci-lint
3131
uses: golangci/golangci-lint-action@v2
@@ -50,7 +50,7 @@ jobs:
5050
uses: actions/checkout@v2
5151
- name: Run tests with coverage
5252
run: |
53-
go mod init gopkg.in/ini.v1
53+
go mod init github.com/go-ini/ini
5454
go mod tidy
5555
go test -v -race -coverprofile=coverage -covermode=atomic ./...
5656
- name: Upload coverage report to Codecov

bench_test.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212
// License for the specific language governing permissions and limitations
1313
// under the License.
1414

15-
package ini_test
15+
package ini
1616

1717
import (
1818
"testing"
19-
20-
"gopkg.in/ini.v1"
2119
)
2220

23-
func newTestFile(block bool) *ini.File {
24-
c, _ := ini.Load([]byte(confData))
21+
func newTestFile(block bool) *File {
22+
c, _ := Load([]byte(confData))
2523
c.BlockMode = block
2624
return c
2725
}

file_test.go

+34-36
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// License for the specific language governing permissions and limitations
1313
// under the License.
1414

15-
package ini_test
15+
package ini
1616

1717
import (
1818
"bytes"
@@ -22,12 +22,10 @@ import (
2222

2323
"github.com/stretchr/testify/assert"
2424
"github.com/stretchr/testify/require"
25-
26-
"gopkg.in/ini.v1"
2725
)
2826

2927
func TestEmpty(t *testing.T) {
30-
f := ini.Empty()
28+
f := Empty()
3129
require.NotNil(t, f)
3230

3331
// Should only have the default section
@@ -38,23 +36,23 @@ func TestEmpty(t *testing.T) {
3836
}
3937

4038
func TestFile_NewSection(t *testing.T) {
41-
f := ini.Empty()
39+
f := Empty()
4240
require.NotNil(t, f)
4341

4442
sec, err := f.NewSection("author")
4543
require.NoError(t, err)
4644
require.NotNil(t, sec)
4745
assert.Equal(t, "author", sec.Name())
4846

49-
assert.Equal(t, []string{ini.DefaultSection, "author"}, f.SectionStrings())
47+
assert.Equal(t, []string{DefaultSection, "author"}, f.SectionStrings())
5048

5149
t.Run("with duplicated name", func(t *testing.T) {
5250
sec, err := f.NewSection("author")
5351
require.NoError(t, err)
5452
require.NotNil(t, sec)
5553

5654
// Does nothing if section already exists
57-
assert.Equal(t, []string{ini.DefaultSection, "author"}, f.SectionStrings())
55+
assert.Equal(t, []string{DefaultSection, "author"}, f.SectionStrings())
5856
})
5957

6058
t.Run("with empty string", func(t *testing.T) {
@@ -65,7 +63,7 @@ func TestFile_NewSection(t *testing.T) {
6563

6664
func TestFile_NonUniqueSection(t *testing.T) {
6765
t.Run("read and write non-unique sections", func(t *testing.T) {
68-
f, err := ini.LoadSources(ini.LoadOptions{
66+
f, err := LoadSources(LoadOptions{
6967
AllowNonUniqueSections: true,
7068
}, []byte(`[Interface]
7169
Address = 192.168.2.1
@@ -114,7 +112,7 @@ AllowedIPs = 192.168.2.4/32
114112
})
115113

116114
t.Run("delete non-unique section", func(t *testing.T) {
117-
f, err := ini.LoadSources(ini.LoadOptions{
115+
f, err := LoadSources(LoadOptions{
118116
AllowNonUniqueSections: true,
119117
}, []byte(`[Interface]
120118
Address = 192.168.2.1
@@ -161,20 +159,20 @@ AllowedIPs = 192.168.2.4/32
161159
})
162160

163161
t.Run("delete all sections", func(t *testing.T) {
164-
f := ini.Empty(ini.LoadOptions{
162+
f := Empty(LoadOptions{
165163
AllowNonUniqueSections: true,
166164
})
167165
require.NotNil(t, f)
168166

169167
_ = f.NewSections("Interface", "Peer", "Peer")
170-
assert.Equal(t, []string{ini.DefaultSection, "Interface", "Peer", "Peer"}, f.SectionStrings())
168+
assert.Equal(t, []string{DefaultSection, "Interface", "Peer", "Peer"}, f.SectionStrings())
171169
f.DeleteSection("Peer")
172-
assert.Equal(t, []string{ini.DefaultSection, "Interface"}, f.SectionStrings())
170+
assert.Equal(t, []string{DefaultSection, "Interface"}, f.SectionStrings())
173171
})
174172
}
175173

176174
func TestFile_NewRawSection(t *testing.T) {
177-
f := ini.Empty()
175+
f := Empty()
178176
require.NotNil(t, f)
179177

180178
sec, err := f.NewRawSection("comments", `1111111111111111111000000000000000001110000
@@ -183,15 +181,15 @@ func TestFile_NewRawSection(t *testing.T) {
183181
require.NotNil(t, sec)
184182
assert.Equal(t, "comments", sec.Name())
185183

186-
assert.Equal(t, []string{ini.DefaultSection, "comments"}, f.SectionStrings())
184+
assert.Equal(t, []string{DefaultSection, "comments"}, f.SectionStrings())
187185
assert.Equal(t, `1111111111111111111000000000000000001110000
188186
111111111111111111100000000000111000000000`, f.Section("comments").Body())
189187

190188
t.Run("with duplicated name", func(t *testing.T) {
191189
sec, err := f.NewRawSection("comments", `1111111111111111111000000000000000001110000`)
192190
require.NoError(t, err)
193191
require.NotNil(t, sec)
194-
assert.Equal(t, []string{ini.DefaultSection, "comments"}, f.SectionStrings())
192+
assert.Equal(t, []string{DefaultSection, "comments"}, f.SectionStrings())
195193

196194
// Overwrite previous existed section
197195
assert.Equal(t, `1111111111111111111000000000000000001110000`, f.Section("comments").Body())
@@ -204,17 +202,17 @@ func TestFile_NewRawSection(t *testing.T) {
204202
}
205203

206204
func TestFile_NewSections(t *testing.T) {
207-
f := ini.Empty()
205+
f := Empty()
208206
require.NotNil(t, f)
209207

210208
assert.NoError(t, f.NewSections("package", "author"))
211-
assert.Equal(t, []string{ini.DefaultSection, "package", "author"}, f.SectionStrings())
209+
assert.Equal(t, []string{DefaultSection, "package", "author"}, f.SectionStrings())
212210

213211
t.Run("with duplicated name", func(t *testing.T) {
214212
assert.NoError(t, f.NewSections("author", "features"))
215213

216214
// Ignore section already exists
217-
assert.Equal(t, []string{ini.DefaultSection, "package", "author", "features"}, f.SectionStrings())
215+
assert.Equal(t, []string{DefaultSection, "package", "author", "features"}, f.SectionStrings())
218216
})
219217

220218
t.Run("with empty string", func(t *testing.T) {
@@ -223,7 +221,7 @@ func TestFile_NewSections(t *testing.T) {
223221
}
224222

225223
func TestFile_GetSection(t *testing.T) {
226-
f, err := ini.Load(fullConf)
224+
f, err := Load(fullConf)
227225
require.NoError(t, err)
228226
require.NotNil(t, f)
229227

@@ -240,7 +238,7 @@ func TestFile_GetSection(t *testing.T) {
240238

241239
func TestFile_Section(t *testing.T) {
242240
t.Run("get a section", func(t *testing.T) {
243-
f, err := ini.Load(fullConf)
241+
f, err := Load(fullConf)
244242
require.NoError(t, err)
245243
require.NotNil(t, f)
246244

@@ -256,7 +254,7 @@ func TestFile_Section(t *testing.T) {
256254
})
257255

258256
t.Run("get default section in lower case with insensitive load", func(t *testing.T) {
259-
f, err := ini.InsensitiveLoad([]byte(`
257+
f, err := InsensitiveLoad([]byte(`
260258
[default]
261259
NAME = ini
262260
VERSION = v1`))
@@ -269,20 +267,20 @@ VERSION = v1`))
269267
}
270268

271269
func TestFile_Sections(t *testing.T) {
272-
f, err := ini.Load(fullConf)
270+
f, err := Load(fullConf)
273271
require.NoError(t, err)
274272
require.NotNil(t, f)
275273

276274
secs := f.Sections()
277-
names := []string{ini.DefaultSection, "author", "package", "package.sub", "features", "types", "array", "note", "comments", "string escapes", "advance"}
275+
names := []string{DefaultSection, "author", "package", "package.sub", "features", "types", "array", "note", "comments", "string escapes", "advance"}
278276
assert.Len(t, secs, len(names))
279277
for i, name := range names {
280278
assert.Equal(t, name, secs[i].Name())
281279
}
282280
}
283281

284282
func TestFile_ChildSections(t *testing.T) {
285-
f, err := ini.Load([]byte(`
283+
f, err := Load([]byte(`
286284
[node]
287285
[node.biz1]
288286
[node.biz2]
@@ -301,16 +299,16 @@ func TestFile_ChildSections(t *testing.T) {
301299
}
302300

303301
func TestFile_SectionStrings(t *testing.T) {
304-
f, err := ini.Load(fullConf)
302+
f, err := Load(fullConf)
305303
require.NoError(t, err)
306304
require.NotNil(t, f)
307305

308-
assert.Equal(t, []string{ini.DefaultSection, "author", "package", "package.sub", "features", "types", "array", "note", "comments", "string escapes", "advance"}, f.SectionStrings())
306+
assert.Equal(t, []string{DefaultSection, "author", "package", "package.sub", "features", "types", "array", "note", "comments", "string escapes", "advance"}, f.SectionStrings())
309307
}
310308

311309
func TestFile_DeleteSection(t *testing.T) {
312310
t.Run("delete a section", func(t *testing.T) {
313-
f := ini.Empty()
311+
f := Empty()
314312
require.NotNil(t, f)
315313

316314
_ = f.NewSections("author", "package", "features")
@@ -320,7 +318,7 @@ func TestFile_DeleteSection(t *testing.T) {
320318
})
321319

322320
t.Run("delete default section", func(t *testing.T) {
323-
f := ini.Empty()
321+
f := Empty()
324322
require.NotNil(t, f)
325323

326324
f.Section("").Key("foo").SetValue("bar")
@@ -339,7 +337,7 @@ key1 = value1
339337
})
340338

341339
t.Run("delete a section with InsensitiveSections", func(t *testing.T) {
342-
f := ini.Empty(ini.LoadOptions{InsensitiveSections: true})
340+
f := Empty(LoadOptions{InsensitiveSections: true})
343341
require.NotNil(t, f)
344342

345343
_ = f.NewSections("author", "package", "features")
@@ -350,7 +348,7 @@ key1 = value1
350348
}
351349

352350
func TestFile_Append(t *testing.T) {
353-
f := ini.Empty()
351+
f := Empty()
354352
require.NotNil(t, f)
355353

356354
assert.NoError(t, f.Append(minimalConf, []byte(`
@@ -369,7 +367,7 @@ func TestFile_WriteTo(t *testing.T) {
369367
}
370368

371369
t.Run("write content to somewhere", func(t *testing.T) {
372-
f, err := ini.Load(fullConf)
370+
f, err := Load(fullConf)
373371
require.NoError(t, err)
374372
require.NotNil(t, f)
375373

@@ -394,7 +392,7 @@ func TestFile_WriteTo(t *testing.T) {
394392
})
395393

396394
t.Run("support multiline comments", func(t *testing.T) {
397-
f, err := ini.Load([]byte(`
395+
f, err := Load([]byte(`
398396
#
399397
# general.domain
400398
#
@@ -423,7 +421,7 @@ test =
423421
})
424422

425423
t.Run("keep leading and trailing spaces in value", func(t *testing.T) {
426-
f, _ := ini.Load([]byte(`[foo]
424+
f, _ := Load([]byte(`[foo]
427425
bar1 = ' val ue1 '
428426
bar2 = """ val ue2 """
429427
bar3 = " val ue3 "
@@ -443,7 +441,7 @@ bar3 = " val ue3 "
443441
}
444442

445443
func TestFile_SaveTo(t *testing.T) {
446-
f, err := ini.Load(fullConf)
444+
f, err := Load(fullConf)
447445
require.NoError(t, err)
448446
require.NotNil(t, f)
449447

@@ -452,7 +450,7 @@ func TestFile_SaveTo(t *testing.T) {
452450
}
453451

454452
func TestFile_WriteToWithOutputDelimiter(t *testing.T) {
455-
f, err := ini.LoadSources(ini.LoadOptions{
453+
f, err := LoadSources(LoadOptions{
456454
KeyValueDelimiterOnWrite: "->",
457455
}, []byte(`[Others]
458456
Cities = HangZhou|Boston
@@ -488,7 +486,7 @@ Note -> Hello world!
488486

489487
// Inspired by https://github.com/go-ini/ini/issues/207
490488
func TestReloadAfterShadowLoad(t *testing.T) {
491-
f, err := ini.ShadowLoad([]byte(`
489+
f, err := ShadowLoad([]byte(`
492490
[slice]
493491
v = 1
494492
v = 2

ini_python_multiline_test.go

-67
This file was deleted.

0 commit comments

Comments
 (0)