Skip to content

Commit 216406c

Browse files
committed
Add test for when minReplicas is nil
1 parent d742467 commit 216406c

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

tests/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ uninstall-ngf: ## Uninstall NGF on configured kind cluster
191191
# Run CEL validation integration tests against a real cluster
192192
.PHONY: test-cel-validation
193193
test-cel-validation:
194+
-make install-crds || true;
194195
-make install-gateway-crds || true;
195196
@if [ -z "$(CEL_TEST_TARGET)" ]; then \
196197
echo "Running all tests in ./cel"; \

tests/cel/common.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,8 @@ func getKubernetesClient(t *testing.T) (k8sClient client.Client) {
6363

6464
// Set up scheme with NGF types
6565
scheme := runtime.NewScheme()
66-
err = ngfAPIv1alpha1.AddToScheme(scheme)
67-
g.Expect(err).ToNot(HaveOccurred())
68-
69-
err = ngfAPIv1alpha2.AddToScheme(scheme)
70-
g.Expect(err).ToNot(HaveOccurred())
66+
g.Expect(ngfAPIv1alpha1.AddToScheme(scheme)).To(Succeed())
67+
g.Expect(ngfAPIv1alpha2.AddToScheme(scheme)).To(Succeed())
7168

7269
k8sClient, err = client.New(k8sConfig, client.Options{Scheme: scheme})
7370
g.Expect(err).ToNot(HaveOccurred())
@@ -96,8 +93,8 @@ func validateCrd(t *testing.T, wantErrors []string, crd client.Object, k8sClient
9693
g := NewWithT(t)
9794
timeoutConfig := framework.DefaultTimeoutConfig()
9895
ctx, cancel := context.WithTimeout(context.Background(), timeoutConfig.KubernetesClientTimeout)
99-
err := k8sClient.Create(ctx, crd)
10096
defer cancel()
97+
err := k8sClient.Create(ctx, crd)
10198

10299
// Clean up after test
103100
defer func() {

tests/cel/nginxproxy_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,19 @@ func TestNginxProxyAutoscaling(t *testing.T) {
165165
},
166166
},
167167
},
168+
{
169+
name: "Validate NginxProxy is valid when MinReplicas is nil",
170+
spec: ngfAPIv1alpha2.NginxProxySpec{
171+
Kubernetes: &ngfAPIv1alpha2.KubernetesSpec{
172+
Deployment: &ngfAPIv1alpha2.DeploymentSpec{
173+
Autoscaling: &ngfAPIv1alpha2.AutoscalingSpec{
174+
MinReplicas: nil,
175+
MaxReplicas: 5,
176+
},
177+
},
178+
},
179+
},
180+
},
168181
}
169182
for _, tt := range tests {
170183
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)