Skip to content

Commit 9b63d04

Browse files
committed
fix: align struct fields and convert gatewayclass_envtest_test.go to GenerateName
- Fix gci lint: align Namespace field with longer GenerateName field - Convert gatewayclass_envtest_test.go Gateway names to GenerateName - Move pre-Create log to after Create so .Name is populated
1 parent 17a07ab commit 9b63d04

File tree

7 files changed

+15
-16
lines changed

7 files changed

+15
-16
lines changed

test/envtest/adminapi_discoverer_envtest_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestDiscoverer_GetAdminAPIsForServiceReturnsAllAddressesCorrectlyPagingThro
8383
es := discoveryv1.EndpointSlice{
8484
ObjectMeta: metav1.ObjectMeta{
8585
GenerateName: "endpointslice-",
86-
Namespace: ns.Name,
86+
Namespace: ns.Name,
8787
Labels: map[string]string{
8888
"kubernetes.io/service-name": serviceName,
8989
},

test/envtest/gateway_envtest_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func createHTTPRoutes(
152152
httpRoute := &gatewayapi.HTTPRoute{
153153
ObjectMeta: metav1.ObjectMeta{
154154
GenerateName: "httproute-",
155-
Namespace: gw.Namespace,
155+
Namespace: gw.Namespace,
156156
},
157157
Spec: gatewayapi.HTTPRouteSpec{
158158
CommonRouteSpec: gatewayapi.CommonRouteSpec{

test/envtest/gatewayclass_envtest_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"time"
77

88
"github.com/go-logr/logr"
9-
"github.com/google/uuid"
109
"github.com/stretchr/testify/require"
1110
corev1 "k8s.io/api/core/v1"
1211
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -77,7 +76,7 @@ func TestGatewayWithGatewayClassReconciliation(t *testing.T) {
7776
IntoSlice(),
7877
},
7978
ObjectMeta: metav1.ObjectMeta{
80-
Name: uuid.NewString(),
79+
GenerateName: "gw-",
8180
},
8281
},
8382
Test: func(
@@ -147,7 +146,7 @@ func TestGatewayWithGatewayClassReconciliation(t *testing.T) {
147146
IntoSlice(),
148147
},
149148
ObjectMeta: metav1.ObjectMeta{
150-
Name: uuid.NewString(),
149+
GenerateName: "gw-",
151150
},
152151
},
153152
Test: func(
@@ -237,7 +236,7 @@ func TestGatewayWithGatewayClassReconciliation(t *testing.T) {
237236
IntoSlice(),
238237
},
239238
ObjectMeta: metav1.ObjectMeta{
240-
Name: uuid.NewString(),
239+
GenerateName: "gw-",
241240
},
242241
},
243242
Test: func(
@@ -381,9 +380,9 @@ func testGatewayWithGatewayClassReconciliation(
381380
}
382381
StartReconciler(ctx, t, scheme, cfg, gwReconciler, WithWatchNamespace(ns.Name))
383382

384-
t.Logf("deploying gateway %s using %s gateway class", tc.Gateway.Name, tc.GatewayClass.Name)
385383
tc.Gateway.Namespace = ns.Name
386384
require.NoError(t, clNamespaced.Create(ctx, &tc.Gateway))
385+
t.Logf("deployed gateway %s using %s gateway class", tc.Gateway.Name, tc.GatewayClass.Name)
387386
t.Cleanup(func() { _ = clNamespaced.Delete(t.Context(), &tc.Gateway) })
388387

389388
tc.Test(ctx, t, clNamespaced, tc.GatewayClass, tc.Gateway, ns)

test/envtest/ingress_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func TestIngressWorksWithServiceBackendsSpecifyingOnlyPortNames(t *testing.T) {
9292
es := discoveryv1.EndpointSlice{
9393
ObjectMeta: metav1.ObjectMeta{
9494
GenerateName: "endpointslice-",
95-
Namespace: ns.Name,
95+
Namespace: ns.Name,
9696
Labels: map[string]string{
9797
"kubernetes.io/service-name": service.Name,
9898
},

test/envtest/k8s.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func CreatePod(ctx context.Context, t *testing.T, client ctrlclient.Client, ns s
3434

3535
pod := corev1.Pod{
3636
ObjectMeta: metav1.ObjectMeta{
37-
Namespace: ns,
37+
Namespace: ns,
3838
GenerateName: "pod-",
3939
},
4040
Spec: corev1.PodSpec{

test/envtest/kongadminapi_controller_envtest_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func TestKongAdminAPIController(t *testing.T) {
143143
},
144144
},
145145
GenerateName: "endpointslice-",
146-
Namespace: adminService.Namespace,
146+
Namespace: adminService.Namespace,
147147
Labels: map[string]string{
148148
"kubernetes.io/service-name": adminService.Name,
149149
},
@@ -222,7 +222,7 @@ func TestKongAdminAPIController(t *testing.T) {
222222
},
223223
},
224224
GenerateName: "endpointslice-",
225-
Namespace: adminService.Namespace,
225+
Namespace: adminService.Namespace,
226226
Labels: map[string]string{
227227
"kubernetes.io/service-name": adminService.Name,
228228
},
@@ -289,7 +289,7 @@ func TestKongAdminAPIController(t *testing.T) {
289289
},
290290
},
291291
GenerateName: "endpointslice-",
292-
Namespace: adminService.Namespace,
292+
Namespace: adminService.Namespace,
293293
Labels: map[string]string{
294294
"kubernetes.io/service-name": adminService.Name,
295295
},
@@ -334,7 +334,7 @@ func TestKongAdminAPIController(t *testing.T) {
334334
},
335335
},
336336
GenerateName: "endpointslice-",
337-
Namespace: adminService.Namespace,
337+
Namespace: adminService.Namespace,
338338
Labels: map[string]string{
339339
"kubernetes.io/service-name": adminService.Name,
340340
},
@@ -425,7 +425,7 @@ func TestKongAdminAPIController(t *testing.T) {
425425
},
426426
},
427427
GenerateName: "endpointslice-",
428-
Namespace: adminService.Namespace,
428+
Namespace: adminService.Namespace,
429429
Labels: map[string]string{
430430
"kubernetes.io/service-name": adminService.Name,
431431
},
@@ -529,7 +529,7 @@ func TestKongAdminAPIController(t *testing.T) {
529529
},
530530
},
531531
GenerateName: "endpointslice-",
532-
Namespace: adminService.Namespace,
532+
Namespace: adminService.Namespace,
533533
Labels: map[string]string{
534534
"kubernetes.io/service-name": adminService.Name,
535535
},

test/envtest/setup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func deployGatewayUsingGatewayClass(ctx context.Context, t *testing.T, client cl
235235
},
236236
},
237237
ObjectMeta: metav1.ObjectMeta{
238-
Namespace: ns.Name,
238+
Namespace: ns.Name,
239239
GenerateName: "gw-",
240240
},
241241
}

0 commit comments

Comments
 (0)