Skip to content

Commit 082f5d3

Browse files
committed
tests: add configuration tests
1 parent 485e2c4 commit 082f5d3

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//golangcitest:args -Efatcontext
2+
//golangcitest:config_path testdata/fatcontext_structpointer.yml
3+
package testdata
4+
5+
import (
6+
"context"
7+
)
8+
9+
type Container struct {
10+
Ctx context.Context
11+
}
12+
13+
func something() func(*Container) {
14+
return func(r *Container) {
15+
ctx := r.Ctx
16+
ctx = context.WithValue(ctx, "key", "val")
17+
r.Ctx = ctx // want "potential nested context in struct pointer"
18+
}
19+
}
20+
21+
func blah(r *Container) {
22+
ctx := r.Ctx
23+
ctx = context.WithValue(ctx, "key", "val")
24+
r.Ctx = ctx // want "potential nested context in struct pointer"
25+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
linters-settings:
2+
fatcontext:
3+
check-struct-pointers: true
4+

0 commit comments

Comments
 (0)