Skip to content

Commit 367311b

Browse files
authored
chore: enable thelper linter (#675)
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 70bee6a commit 367311b

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

.golangci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ linters:
2424
- revive
2525
- staticcheck
2626
- testifylint
27-
# - thelper
27+
- thelper
2828
# - unparam
2929
- unused
3030
- usestdlibvars

pkg/cache/cluster_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ var (
7474
- hostname: localhost`, testCreationTime.UTC().Format(time.RFC3339)))
7575
)
7676

77-
func newCluster(t testing.TB, objs ...runtime.Object) *clusterCache {
78-
cache := newClusterWithOptions(t, []UpdateSettingsFunc{}, objs...)
77+
func newCluster(tb testing.TB, objs ...runtime.Object) *clusterCache {
78+
tb.Helper()
79+
cache := newClusterWithOptions(tb, []UpdateSettingsFunc{}, objs...)
7980

80-
t.Cleanup(func() {
81+
tb.Cleanup(func() {
8182
cache.Invalidate()
8283
})
8384

@@ -860,6 +861,7 @@ func ExampleNewClusterCache_resourceUpdatedEvents() {
860861
}
861862

862863
func getResourceKey(t *testing.T, obj runtime.Object) kube.ResourceKey {
864+
t.Helper()
863865
gvk := obj.GetObjectKind().GroupVersionKind()
864866
m, err := meta.Accessor(obj)
865867
require.NoError(t, err)

pkg/diff/diff_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func newDeployment() *appsv1.Deployment {
151151
}
152152

153153
func diff(t *testing.T, config, live *unstructured.Unstructured, options ...Option) *DiffResult {
154+
t.Helper()
154155
res, err := Diff(config, live, options...)
155156
assert.NoError(t, err)
156157
return res
@@ -754,6 +755,7 @@ func TestUnsortedEndpoints(t *testing.T) {
754755
}
755756

756757
func buildGVKParser(t *testing.T) *managedfields.GvkParser {
758+
t.Helper()
757759
document := &openapi_v2.Document{}
758760
err := proto.Unmarshal(testdata.OpenAPIV2Doc, document)
759761
if err != nil {

pkg/health/health_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ import (
1515
)
1616

1717
func assertAppHealth(t *testing.T, yamlPath string, expectedStatus HealthStatusCode) {
18-
health := getHealthStatus(yamlPath, t)
18+
t.Helper()
19+
health := getHealthStatus(t, yamlPath)
1920
assert.NotNil(t, health)
2021
assert.Equal(t, expectedStatus, health.Status)
2122
}
2223

23-
func getHealthStatus(yamlPath string, t *testing.T) *HealthStatus {
24+
func getHealthStatus(t *testing.T, yamlPath string) *HealthStatus {
25+
t.Helper()
2426
yamlBytes, err := os.ReadFile(yamlPath)
2527
require.NoError(t, err)
2628
var obj unstructured.Unstructured
@@ -69,7 +71,7 @@ func TestIngressHealth(t *testing.T) {
6971
}
7072

7173
func TestCRD(t *testing.T) {
72-
assert.Nil(t, getHealthStatus("./testdata/knative-service.yaml", t))
74+
assert.Nil(t, getHealthStatus(t, "./testdata/knative-service.yaml"))
7375
}
7476

7577
func TestJob(t *testing.T) {
@@ -108,8 +110,8 @@ func TestPod(t *testing.T) {
108110
}
109111

110112
func TestApplication(t *testing.T) {
111-
assert.Nil(t, getHealthStatus("./testdata/application-healthy.yaml", t))
112-
assert.Nil(t, getHealthStatus("./testdata/application-degraded.yaml", t))
113+
assert.Nil(t, getHealthStatus(t, "./testdata/application-healthy.yaml"))
114+
assert.Nil(t, getHealthStatus(t, "./testdata/application-degraded.yaml"))
113115
}
114116

115117
func TestAPIService(t *testing.T) {

0 commit comments

Comments
 (0)