Skip to content

Commit 8cecedd

Browse files
committed
INTEGRATION-TESTS-V3 - add another integration test for glob-patterns
1 parent 2ddbfd4 commit 8cecedd

File tree

1 file changed

+55
-4
lines changed

1 file changed

+55
-4
lines changed

integration/plain_glob_test.go

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package integration
22

33
import (
4+
"os"
45
"os/exec"
56
"strings"
67
"testing"
78
)
89

910
func TestEnvsubstIntegration_NoSubst_GlobPatterns_Yaml(t *testing.T) {
1011

11-
// if os.Getenv(integrationTestEnv) != integrationTestFlag {
12-
// t.Log("integration test was skipped due to configuration")
13-
// return
14-
// }
12+
if os.Getenv(integrationTestEnv) != integrationTestFlag {
13+
t.Log("integration test was skipped due to configuration")
14+
return
15+
}
1516

1617
printEnvsubstVersionInfo(t)
1718

@@ -50,8 +51,58 @@ func TestEnvsubstIntegration_NoSubst_GlobPatterns_Yaml(t *testing.T) {
5051
for _, er := range unExpectResources {
5152
unExpectedOutput := strings.Contains(stringOutput, er)
5253
if unExpectedOutput {
54+
t.Errorf("Expected substituted output does not contain '%s'", er)
55+
}
56+
}
57+
58+
}
59+
60+
func TestEnvsubstIntegration_NoSubst_GlobPatterns_Json(t *testing.T) {
61+
62+
if os.Getenv(integrationTestEnv) != integrationTestFlag {
63+
t.Log("integration test was skipped due to configuration")
64+
return
65+
}
66+
67+
printEnvsubstVersionInfo(t)
68+
69+
namespaceName := "kubectl-envsubst-plain-glob"
70+
createNs(t, namespaceName)
71+
72+
// Setup context
73+
setContextNs(t, namespaceName)
74+
75+
// Run kubectl-envsubst
76+
77+
cmdEnvsubstApply := exec.Command("kubectl", "envsubst", "apply", "-f", "immutable_data/resolve/plain-glob/*.json")
78+
output, err := cmdEnvsubstApply.CombinedOutput()
79+
stringOutput := string(output)
80+
if err != nil {
81+
t.Fatalf("Failed to run kubectl envsubst: %v, output: %s", err, stringOutput)
82+
}
83+
t.Logf("\n%s\n", strings.TrimSpace(stringOutput))
84+
85+
expectResources := []string{
86+
"cm-3-level-0", // *.json
87+
}
88+
89+
unExpectResources := []string{
90+
"cm-1-level-0", // *.yaml
91+
"cm-2-level-0", // *.yaml
92+
}
93+
94+
for _, er := range expectResources {
95+
expectedOutput := strings.Contains(stringOutput, er)
96+
if !expectedOutput {
5397
t.Errorf("Expected substituted output to contain '%s', got %s", er, stringOutput)
5498
}
5599
}
56100

101+
for _, er := range unExpectResources {
102+
unExpectedOutput := strings.Contains(stringOutput, er)
103+
if unExpectedOutput {
104+
t.Errorf("Expected substituted output does not contain '%s'", er)
105+
}
106+
}
107+
57108
}

0 commit comments

Comments
 (0)