summaryrefslogtreecommitdiff
path: root/pkg/hooks/exec
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-01-14 09:53:02 +0100
committerValentin Rothberg <rothberg@redhat.com>2020-01-14 10:51:59 +0100
commitcf1f3191d2be691b482ac86f9476c180f608ddbe (patch)
tree16b5c74883be69aef8e567bc089b3656b6fb14fa /pkg/hooks/exec
parenta1028697465029f3e7b100de843eb7e5e2948246 (diff)
downloadpodman-cf1f3191d2be691b482ac86f9476c180f608ddbe.tar.gz
podman-cf1f3191d2be691b482ac86f9476c180f608ddbe.tar.bz2
podman-cf1f3191d2be691b482ac86f9476c180f608ddbe.zip
make lint: include unit tests
Include the unit tests (i.e., _test.go files) for linting to make the tests more robust and enforce the linters' coding styles etc. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg/hooks/exec')
-rw-r--r--pkg/hooks/exec/exec_test.go6
-rw-r--r--pkg/hooks/exec/runtimeconfigfilter_test.go5
2 files changed, 7 insertions, 4 deletions
diff --git a/pkg/hooks/exec/exec_test.go b/pkg/hooks/exec/exec_test.go
index 7aac315cb..1e105373d 100644
--- a/pkg/hooks/exec/exec_test.go
+++ b/pkg/hooks/exec/exec_test.go
@@ -94,7 +94,7 @@ func TestRunEnvironment(t *testing.T) {
Path: path,
Args: []string{"sh", "-c", "env"},
}
- for _, test := range []struct {
+ for _, tt := range []struct {
name string
env []string
expected map[string]string
@@ -120,6 +120,7 @@ func TestRunEnvironment(t *testing.T) {
},
},
} {
+ test := tt
t.Run(test.name, func(t *testing.T) {
var stderr, stdout bytes.Buffer
hook.Env = test.env
@@ -147,7 +148,7 @@ func TestRunCancel(t *testing.T) {
Args: []string{"sh", "-c", "echo waiting; sleep 2; echo done"},
}
one := 1
- for _, test := range []struct {
+ for _, tt := range []struct {
name string
contextTimeout time.Duration
hookTimeout *int
@@ -174,6 +175,7 @@ func TestRunCancel(t *testing.T) {
expectedRunError: context.DeadlineExceeded,
},
} {
+ test := tt
t.Run(test.name, func(t *testing.T) {
ctx := context.Background()
var stderr, stdout bytes.Buffer
diff --git a/pkg/hooks/exec/runtimeconfigfilter_test.go b/pkg/hooks/exec/runtimeconfigfilter_test.go
index 52d590d14..48dd2f998 100644
--- a/pkg/hooks/exec/runtimeconfigfilter_test.go
+++ b/pkg/hooks/exec/runtimeconfigfilter_test.go
@@ -25,9 +25,9 @@ func pointerFileMode(value os.FileMode) *os.FileMode {
}
func TestRuntimeConfigFilter(t *testing.T) {
- unexpectedEndOfJSONInput := json.Unmarshal([]byte("{\n"), nil)
+ unexpectedEndOfJSONInput := json.Unmarshal([]byte("{\n"), nil) //nolint
- for _, test := range []struct {
+ for _, tt := range []struct {
name string
contextTimeout time.Duration
hooks []spec.Hook
@@ -244,6 +244,7 @@ func TestRuntimeConfigFilter(t *testing.T) {
expectedRunError: unexpectedEndOfJSONInput,
},
} {
+ test := tt
t.Run(test.name, func(t *testing.T) {
ctx := context.Background()
if test.contextTimeout > 0 {