Skip to content

Commit 609cc80

Browse files
committed
review: add fix tests
1 parent 7904365 commit 609cc80

File tree

5 files changed

+134
-0
lines changed

5 files changed

+134
-0
lines changed

pkg/golinters/embeddedstructfieldcheck/embeddedstructfieldcheck_integration_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ import (
99
func TestFromTestdata(t *testing.T) {
1010
integration.RunTestdata(t)
1111
}
12+
13+
func TestFix(t *testing.T) {
14+
integration.RunFix(t)
15+
}
16+
17+
func TestFixPathPrefix(t *testing.T) {
18+
integration.RunFixPathPrefix(t)
19+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//golangcitest:args -Eembeddedstructfieldcheck
2+
//golangcitest:expected_exitcode 0
3+
package testdata
4+
5+
import "time"
6+
7+
type ValidStructWithSingleLineComments struct {
8+
// time.Time Single line comment
9+
time.Time
10+
11+
// version Single line comment
12+
version int
13+
}
14+
15+
type StructWithSingleLineComments struct {
16+
// time.Time Single line comment
17+
time.Time // want `there must be an empty line separating embedded fields from regular fields`
18+
19+
// version Single line comment
20+
version int
21+
}
22+
23+
type StructWithMultiLineComments struct {
24+
// time.Time Single line comment
25+
time.Time // want `there must be an empty line separating embedded fields from regular fields`
26+
27+
// version Single line comment
28+
// very long comment
29+
version int
30+
}
31+
32+
type A struct {
33+
// comment
34+
ValidStructWithSingleLineComments
35+
// C is foo
36+
StructWithSingleLineComments // want `there must be an empty line separating embedded fields from regular fields`
37+
38+
D string
39+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//golangcitest:args -Eembeddedstructfieldcheck
2+
//golangcitest:expected_exitcode 0
3+
package testdata
4+
5+
import (
6+
"time"
7+
)
8+
9+
type ValidStruct struct {
10+
time.Time
11+
12+
version int
13+
}
14+
15+
type NoSpaceStruct struct {
16+
time.Time // want `there must be an empty line separating embedded fields from regular fields`
17+
version int
18+
}
19+
20+
type EmbeddedWithPointers struct {
21+
*time.Time // want `there must be an empty line separating embedded fields from regular fields`
22+
version int
23+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//golangcitest:args -Eembeddedstructfieldcheck
2+
//golangcitest:expected_exitcode 0
3+
package testdata
4+
5+
import "time"
6+
7+
type ValidStructWithSingleLineComments struct {
8+
// time.Time Single line comment
9+
time.Time
10+
11+
// version Single line comment
12+
version int
13+
}
14+
15+
type StructWithSingleLineComments struct {
16+
// time.Time Single line comment
17+
time.Time // want `there must be an empty line separating embedded fields from regular fields`
18+
19+
// version Single line comment
20+
version int
21+
}
22+
23+
type StructWithMultiLineComments struct {
24+
// time.Time Single line comment
25+
time.Time // want `there must be an empty line separating embedded fields from regular fields`
26+
27+
// version Single line comment
28+
// very long comment
29+
version int
30+
}
31+
32+
type A struct {
33+
// comment
34+
ValidStructWithSingleLineComments
35+
// C is foo
36+
StructWithSingleLineComments // want `there must be an empty line separating embedded fields from regular fields`
37+
38+
D string
39+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//golangcitest:args -Eembeddedstructfieldcheck
2+
//golangcitest:expected_exitcode 0
3+
package testdata
4+
5+
import (
6+
"time"
7+
)
8+
9+
type ValidStruct struct {
10+
time.Time
11+
12+
version int
13+
}
14+
15+
type NoSpaceStruct struct {
16+
time.Time // want `there must be an empty line separating embedded fields from regular fields`
17+
18+
version int
19+
}
20+
21+
type EmbeddedWithPointers struct {
22+
*time.Time // want `there must be an empty line separating embedded fields from regular fields`
23+
24+
version int
25+
}

0 commit comments

Comments
 (0)