Skip to content

Commit 6a6cd77

Browse files
authored
tests: split default config files into dedicated package (#158)
* tests: move default config to dedicated package * chore: fix golangci-lint * chore: fix wrong move
1 parent c862f08 commit 6a6cd77

22 files changed

+32
-14
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
go-version: stable
1616
- uses: golangci/golangci-lint-action@v4
1717
with:
18-
version: v1.57.2
18+
version: v1.62.2
1919

2020
tests:
2121
# run after golangci-lint action to not produce duplicated errors

.golangci.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,36 +39,28 @@ linters:
3939
enable-all: true
4040
disable:
4141
- cyclop
42-
- deadcode
4342
- depguard
4443
- dupl
4544
- dupword
46-
- exhaustivestruct
4745
- exhaustruct
46+
- exportloopref
4847
- forbidigo
4948
- funlen
5049
- gci
5150
- gocognit
5251
- gocyclo
5352
- godox
54-
- golint
55-
- gomnd
56-
- ifshort
57-
- interfacer
53+
- mnd
5854
- lll
5955
- maintidx
60-
- maligned
6156
- nakedret
6257
- nestif
6358
- nlreturn
64-
- nosnakecase
6559
- paralleltest
6660
- prealloc
6761
- rowserrcheck
68-
- scopelint
69-
- structcheck
62+
- tparallel
7063
- testpackage
71-
- varcheck
7264
- varnamelen
7365
- wastedassign
7466

testdata/src/default_config/else_if.go renamed to testdata/src/default_config/else_if/else_if.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package testdata
2+
13
func fn() {
24
if true { // want "block should not start with a whitespace"
35

testdata/src/default_config/else_if.go.golden renamed to testdata/src/default_config/else_if/else_if.go.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package testdata
2+
13
func fn() {
24
if true { // want "block should not start with a whitespace"
35
fmt.Println("a")
@@ -11,6 +13,7 @@ func fn() {
1113
fmt.Println("c")
1214
fmt.Println("c")
1315
fmt.Println("c")
16+
1417
return // want "return statements should not be cuddled if block has more than two lines"
1518
} // want "block should not end with a whitespace"
1619
}

wsl_test.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,30 @@ func TestWIP(t *testing.T) {
1616

1717
func TestDefaultConfig(t *testing.T) {
1818
testdata := analysistest.TestData()
19-
analyzer := NewAnalyzer(nil)
2019

21-
analysistest.RunWithSuggestedFixes(t, testdata, analyzer, "default_config")
20+
testCases := []struct {
21+
dir string
22+
}{
23+
{dir: "defer"},
24+
{dir: "doc_examples"},
25+
{dir: "else_if"},
26+
{dir: "fix_advanced"},
27+
{dir: "fix_cuddle_blocks"},
28+
{dir: "generated"},
29+
{dir: "generated_file"},
30+
{dir: "generic_handling"},
31+
{dir: "multiline_case"},
32+
{dir: "remove_whitespace"},
33+
}
34+
35+
for _, test := range testCases {
36+
t.Run(test.dir, func(t *testing.T) {
37+
t.Parallel()
38+
39+
analyzer := NewAnalyzer(nil)
40+
analysistest.RunWithSuggestedFixes(t, testdata, analyzer, filepath.Join("default_config", test.dir))
41+
})
42+
}
2243
}
2344

2445
func TestWithConfig(t *testing.T) {

0 commit comments

Comments
 (0)