8000 address review comments · nginx/kubernetes-ingress@ffcf80d · GitHub
[go: up one dir, main page]

Skip to content

Commit ffcf80d

Browse files
committed
address review comments
1 parent 8a9ed06 commit ffcf80d

File tree

5 files changed

+58
-5
lines changed

5 files changed

+58
-5
lines changed

charts/nginx-ingress/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,10 @@ controller:
571571
## Enable the startup probe.
572572
enable: false
573573

574-
# ## Set the port where the startup endpoint is exposed.
574+
# ## Set the port where the startup endpoint is exposed. This is a required value if startupStatus.enable is true.
575575
# port: 9999
576576

577-
# # # path to the startup endpoint.
577+
# ## path to the startup endpoint. This is a required value if startupStatus.enable is true.
578578
# path: /
579579

580580
# ## The number of seconds after the Ingress Controller pod has started before startup probes are initiated.

charts/tests/__snapshots__/helmunit_test.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9531,7 +9531,7 @@ metadata:
95319531
app.kubernetes.io/managed-by: Helm
95329532
---
95339533

9534-
[TestHelmNICTemplate/startupStatus - 1]
9534+
[TestHelmNICTemplate/startupStatusValid - 1]
95359535
/-/-/-/
95369536
# Source: nginx-ingress/templates/controller-serviceaccount.yaml
95379537
apiVersion: v1

charts/tests/helmunit_test.go

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package test
55
import (
66
"os"
77
"path/filepath"
8+
"strings"
89
"testing"
910

1011
"github.com/gkampitakis/go-snaps/snaps"
@@ -130,8 +131,8 @@ func TestHelmNICTemplate(t *testing.T) {
130131
releaseName: "app-protect-waf-agentv2",
131132
namespace: "default",
132133
},
133-
"startupStatus": {
134-
valuesFile: "testdata/startupstatus.yaml",
134+
"startupStatusValid": {
135+
valuesFile: "testdata/startupstatus-valid.yaml",
135136
releaseName: "startupstatus",
136137
namespace: "default",
137138
},
@@ -160,3 +161,51 @@ func TestHelmNICTemplate(t *testing.T) {
160161
})
161162
}
162163
}
164+
165+
// Test for negative cases where helm template rendering should fail
166+
func TestHelmNICTemplateNegative(t *testing.T) {
167+
t.Parallel()
168+
169+
negativeTests := map[string]struct {
170+
valuesFile string
171+
releaseName string
172+
namespace string
173+
expectedErrorMsg string
174+
}{
175+
"startupStatusInvalid": {
176+
valuesFile: "testdata/startupstatus-invalid.yaml",
177+
releaseName: "startupstatus-invalid",
178+
namespace: "default",
179+
expectedErrorMsg: "port is required",
180+
},
181+
}
182+
183+
// Path to the helm chart we will test
184+
helmChartPath, err := filepath.Abs("../nginx-ingress")
185+
if err != nil {
186+
t.Fatal("Failed to open helm chart path ../nginx-ingress")
187+
}
188+
189+
for testName, tc := range negativeTests {
190+
t.Run(testName, func(t *testing.T) {
191+
options := &helm.Options{
192+
KubectlOptions: k8s.NewKubectlOptions("", "", tc.namespace),
193+
}
194+
195+
if tc.valuesFile != "" {
196+
options.ValuesFiles = []string{tc.valuesFile}
197+
}
198+
_, err := helm.RenderTemplateE(t, options, helmChartPath, tc.releaseName, make([]string, 0))
199+
200+
if err == nil {
201+
t.Fatalf("Expected helm template to fail for invalid configuration, but it succeeded")
202+
}
203+
204+
if tc.expectedErrorMsg != "" && !strings.Contains(err.Error(), tc.expectedErrorMsg) {
205+
t.Fatalf("Expected error to contain '%s', but got: %s", tc.expectedErrorMsg, err.Error())
206+
}
207+
208+
t.Logf("Expected failure occurred: %s", err.Error())
209+
})
210+
}
211+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
controller:
2+
startupStatus:
3+
enable: true
4+
# All other required values missing
File renamed without changes.

0 commit comments

Comments
 (0)
0