Skip to content

Commit 4a6e84e

Browse files
committed
Fix test failures
1 parent d273281 commit 4a6e84e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

internal/framework/helpers/helpers_test.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import (
66
"text/template"
77

88
. "github.com/onsi/gomega"
9+
controllerruntime "sigs.k8s.io/controller-runtime"
910
"sigs.k8s.io/controller-runtime/pkg/client"
1011
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
1112
gatewayv1alpha3 "sigs.k8s.io/gateway-api/apis/v1alpha3"
1213

13-
corev1 "k8s.io/api/core/v1"
14+
ngfAPIv1alpha1 "github.com/nginx/nginx-gateway-fabric/v2/apis/v1alpha1"
1415

1516
"github.com/nginx/nginx-gateway-fabric/v2/internal/framework/helpers"
1617
)
@@ -131,7 +132,6 @@ func TestMustReturnUniqueResourceName(t *testing.T) {
131132
uniqueName := helpers.UniqueResourceName(name)
132133

133134
g.Expect(uniqueName).To(HavePrefix(name))
134-
g.Expect(uniqueName).To(HaveSuffix("-"))
135135
g.Expect(len(uniqueName)).To(BeNumerically(">", len(name)))
136136
}
137137

@@ -140,12 +140,22 @@ func TestMustCreateKubernetesClient(t *testing.T) {
140140
g := NewWithT(t)
141141

142142
k8sClient, err := helpers.GetKubernetesClient()
143+
143144
g.Expect(err).ToNot(HaveOccurred())
144145
g.Expect(k8sClient).ToNot(BeNil())
145146

146147
// Check that the client can be used to list namespaces
147-
namespaces := &corev1.NamespaceList{}
148-
err = k8sClient.List(context.Background(), namespaces)
148+
nginxGateway := &ngfAPIv1alpha1.NginxGateway{
149+
ObjectMeta: controllerruntime.ObjectMeta{
150+
Name: helpers.UniqueResourceName("test-nginx-gateway"),
151+
Namespace: "default",
152+
},
153+
}
154+
// Clean up after test
155+
defer func() {
156+
_ = k8sClient.Delete(context.Background(), nginxGateway)
157+
}()
158+
err = k8sClient.Create(context.Background(), nginxGateway)
149159
g.Expect(err).ToNot(HaveOccurred())
150-
g.Expect(namespaces.Items).ToNot(BeEmpty())
160+
g.Expect(nginxGateway).ToNot(BeNil())
151161
}

0 commit comments

Comments
 (0)