Skip to content

Commit

Permalink
ci(lint): enable thelper linter
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgb committed Jan 19, 2025
1 parent da5cc51 commit 6b12886
Show file tree
Hide file tree
Showing 18 changed files with 99 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ linters:
- staticcheck
- stylecheck
- tenv
#- thelper
- thelper
#- tparallel
- typecheck
- unconvert
Expand Down
1 change: 1 addition & 0 deletions core/clustersmngr/factory_caches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func TestClusterSet_Set(t *testing.T) {
}

func newTestCluster(t *testing.T, name, server string) cluster.Cluster {
t.Helper()
c, err := cluster.NewSingleCluster(name, &rest.Config{Host: server}, nil, kube.UserPrefixes{})
if err != nil {
t.Error("Expected error to be nil, got", err)
Expand Down
2 changes: 2 additions & 0 deletions core/clustersmngr/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestMain(m *testing.M) {
}

func makeLeafCluster(t *testing.T, name string) cluster.Cluster {
t.Helper()
cluster, err := cluster.NewSingleCluster(name, k8sEnv.Rest, nil, kube.UserPrefixes{})
if err != nil {
t.Error("Expected err to be nil, got", err)
Expand All @@ -40,6 +41,7 @@ func makeLeafCluster(t *testing.T, name string) cluster.Cluster {
}

func makeUnreachableLeafCluster(t *testing.T, name string) cluster.Cluster {
t.Helper()
c := rest.CopyConfig(k8sEnv.Rest)

// hopefully no k8s server is listening here
Expand Down
4 changes: 2 additions & 2 deletions core/logger/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ var (
)

func redirectStdout(t *testing.T) (*os.File, *os.File) {
g := NewGomegaWithT(t)
t.Helper()
g := NewGomegaWithT(t)

oldStdout := os.Stdout
r, w, err := os.Pipe()
Expand All @@ -180,8 +180,8 @@ func redirectStdout(t *testing.T) (*os.File, *os.File) {
}

func getLogs(t *testing.T, r, w *os.File) []byte {
g := NewGomegaWithT(t)
t.Helper()
g := NewGomegaWithT(t)

w.Close()

Expand Down
1 change: 1 addition & 0 deletions core/nsaccess/nsaccess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ func makeRole(ns *corev1.Namespace) types.NamespacedName {
}

func createRole(t *testing.T, cl client.Client, key types.NamespacedName, rules []rbacv1.PolicyRule) {
t.Helper()
role := &rbacv1.Role{
ObjectMeta: metav1.ObjectMeta{Name: "test-role", Namespace: key.Namespace},
Rules: rules,
Expand Down
2 changes: 1 addition & 1 deletion core/server/crd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestIsAvailable(t *testing.T) {

ctx := context.Background()

c := makeGRPCServer(ctx, k8sEnv.Rest, t)
c := makeGRPCServer(ctx, t, k8sEnv.Rest)

scheme, err := kube.CreateScheme()
g.Expect(err).NotTo(HaveOccurred())
Expand Down
2 changes: 1 addition & 1 deletion core/server/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestListEvents(t *testing.T) {

ctx := context.Background()

c := makeGRPCServer(ctx, k8sEnv.Rest, t)
c := makeGRPCServer(ctx, t, k8sEnv.Rest)

scheme, err := kube.CreateScheme()
g.Expect(err).To(BeNil())
Expand Down
24 changes: 12 additions & 12 deletions core/server/fluxruntime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestGetReconciledObjects(t *testing.T) {

ctx := context.Background()

c := makeGRPCServer(ctx, k8sEnv.Rest, t)
c := makeGRPCServer(ctx, t, k8sEnv.Rest)

scheme, err := kube.CreateScheme()
g.Expect(err).To(BeNil())
Expand Down Expand Up @@ -198,7 +198,7 @@ func TestGetReconciledObjectsWithSecret(t *testing.T) {

ctx := context.Background()

c := makeGRPCServer(ctx, k8sEnv.Rest, t)
c := makeGRPCServer(ctx, t, k8sEnv.Rest)

scheme, err := kube.CreateScheme()
g.Expect(err).To(BeNil())
Expand Down Expand Up @@ -308,8 +308,8 @@ func TestGetChildObjects(t *testing.T) {
g.Expect(err).To(BeNil())

client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(&ns, deployment, rs).Build()
cfg := makeServerConfig(client, t, "")
c := makeServer(ctx, cfg, t)
cfg := makeServerConfig(t, client, "")
c := makeServer(ctx, t, cfg)

res, err := c.GetChildObjects(ctx, &pb.GetChildObjectsRequest{
ParentUid: string(deployment.UID),
Expand Down Expand Up @@ -384,8 +384,8 @@ func TestListFluxRuntimeObjects(t *testing.T) {
scheme, err := kube.CreateScheme()
g.Expect(err).To(BeNil())
client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(tt.objects...).Build()
cfg := makeServerConfig(client, t, "")
c := makeServer(ctx, cfg, t)
cfg := makeServerConfig(t, client, "")
c := makeServer(ctx, t, cfg)
res, err := c.ListFluxRuntimeObjects(ctx, &pb.ListFluxRuntimeObjectsRequest{})
g.Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -453,8 +453,8 @@ func TestListRuntimeObjects(t *testing.T) {
scheme, err := kube.CreateScheme()
g.Expect(err).To(BeNil())
client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(tt.objects...).Build()
cfg := makeServerConfig(client, t, "")
c := makeServer(ctx, cfg, t)
cfg := makeServerConfig(t, client, "")
c := makeServer(ctx, t, cfg)

res, err := c.ListRuntimeObjects(ctx, &pb.ListRuntimeObjectsRequest{})

Expand Down Expand Up @@ -520,8 +520,8 @@ func TestListFluxCrds(t *testing.T) {
g.Expect(err).To(BeNil())

client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(crd1, crd2).Build()
cfg := makeServerConfig(client, t, "")
c := makeServer(ctx, cfg, t)
cfg := makeServerConfig(t, client, "")
c := makeServer(ctx, t, cfg)

res, err := c.ListFluxCrds(ctx, &pb.ListFluxCrdsRequest{})

Expand Down Expand Up @@ -578,8 +578,8 @@ func TestListRuntimeCrds(t *testing.T) {
scheme, err := kube.CreateScheme()
g.Expect(err).To(BeNil())
client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(tt.objects...).Build()
cfg := makeServerConfig(client, t, "")
c := makeServer(ctx, cfg, t)
cfg := makeServerConfig(t, client, "")
c := makeServer(ctx, t, cfg)

res, err := c.ListRuntimeCrds(ctx, &pb.ListRuntimeCrdsRequest{})
g.Expect(err).NotTo(HaveOccurred())
Expand Down
20 changes: 10 additions & 10 deletions core/server/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ func TestGetInventoryKustomization(t *testing.T) {
g.Expect(err).To(BeNil())

client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(&ns, &anotherNs, kust, deployment, rs).Build()
cfg := makeServerConfig(client, t, "")
c := makeServer(ctx, cfg, t)
cfg := makeServerConfig(t, client, "")
c := makeServer(ctx, t, cfg)

res, err := c.GetInventory(ctx, &pb.GetInventoryRequest{
Namespace: ns.Name,
Expand Down Expand Up @@ -195,8 +195,8 @@ func TestGetBlankInventoryKustomization(t *testing.T) {
g.Expect(err).To(BeNil())

client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(kust, deployment).Build()
cfg := makeServerConfig(client, t, "")
c := makeServer(ctx, cfg, t)
cfg := makeServerConfig(t, client, "")
c := makeServer(ctx, t, cfg)

res, err := c.GetInventory(ctx, &pb.GetInventoryRequest{
Namespace: ns,
Expand Down Expand Up @@ -274,8 +274,8 @@ func TestGetInventoryHelmRelease(t *testing.T) {
}

client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(ns, helm1, secret, cm).Build()
cfg := makeServerConfig(client, t, "")
c := makeServer(ctx, cfg, t)
cfg := makeServerConfig(t, client, "")
c := makeServer(ctx, t, cfg)

res, err := c.GetInventory(ctx, &pb.GetInventoryRequest{
Namespace: ns.Name,
Expand Down Expand Up @@ -363,8 +363,8 @@ func TestGetInventoryHelmReleaseNoNSResources(t *testing.T) {
client := fake.NewClientBuilder().WithScheme(scheme).
WithRESTMapper(testrestmapper.TestOnlyStaticRESTMapper(scheme)).
WithRuntimeObjects(ns, helm1, secret, cm).Build()
cfg := makeServerConfig(client, t, "")
c := makeServer(ctx, cfg, t)
cfg := makeServerConfig(t, client, "")
c := makeServer(ctx, t, cfg)

res, err := c.GetInventory(ctx, &pb.GetInventoryRequest{
Namespace: ns.Name,
Expand Down Expand Up @@ -413,8 +413,8 @@ func TestGetInventoryHelmReleaseWithKubeconfig(t *testing.T) {
}

client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(ns, helm1).Build()
cfg := makeServerConfig(client, t, "")
c := makeServer(ctx, cfg, t)
cfg := makeServerConfig(t, client, "")
c := makeServer(ctx, t, cfg)

res, err := c.GetInventory(ctx, &pb.GetInventoryRequest{
Namespace: ns.Name,
Expand Down
Loading

0 comments on commit 6b12886

Please sign in to comment.