Skip to content

Commit 8c9c1d1

Browse files
authored
build: Lint for missed errors in tests too (#287)
1 parent fa1c6e7 commit 8c9c1d1

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

.golangci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ linters-settings:
7474

7575
issues:
7676
exclude-rules:
77-
# ignore errcheck for code under a /test folder
78-
- path: "test/*"
79-
linters:
80-
- errcheck
8177
# ignore errcheck for flags.Parse (it is expected that we flag.ExitOnError)
8278
# ignore response.WriteError as it always returns the err it was passed
8379
- source: "flags.Parse|response.WriteError"

pkg/handlers/generic/mutation/imageregistries/credentials/tests/generate_patches.go

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"testing"
99

1010
"github.com/onsi/gomega"
11+
"github.com/stretchr/testify/require"
1112
corev1 "k8s.io/api/core/v1"
1213
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1314
"k8s.io/apiserver/pkg/storage/names"
@@ -35,22 +36,31 @@ func TestGeneratePatches(
3536

3637
// Server side apply does not work with the fake client, hack around it by pre-creating empty Secrets
3738
// https://github.com/kubernetes-sigs/controller-runtime/issues/2341
38-
fakeClient.Create(
39-
context.Background(),
40-
newTestSecret(validSecretName, request.Namespace),
39+
require.NoError(
40+
t,
41+
fakeClient.Create(
42+
context.Background(),
43+
newTestSecret(validSecretName, request.Namespace),
44+
),
4145
)
42-
fakeClient.Create(
43-
context.Background(),
44-
newEmptySecret(
45-
request.KubeadmControlPlaneTemplateRequestObjectName+"-registry-config",
46-
request.Namespace,
46+
require.NoError(
47+
t,
48+
fakeClient.Create(
49+
context.Background(),
50+
newEmptySecret(
51+
request.KubeadmControlPlaneTemplateRequestObjectName+"-registry-config",
52+
request.Namespace,
53+
),
4754
),
4855
)
49-
fakeClient.Create(
50-
context.Background(),
51-
newEmptySecret(
52-
request.KubeadmConfigTemplateRequestObjectName+"-registry-config",
53-
request.Namespace,
56+
require.NoError(
57+
t,
58+
fakeClient.Create(
59+
context.Background(),
60+
newEmptySecret(
61+
request.KubeadmConfigTemplateRequestObjectName+"-registry-config",
62+
request.Namespace,
63+
),
5464
),
5565
)
5666

0 commit comments

Comments
 (0)