Skip to content

Commit 8692802

Browse files
committed
INTEGRATION-TESTS-V3 - add integration test for --recursive option
1 parent 8cecedd commit 8692802

File tree

8 files changed

+125
-0
lines changed

8 files changed

+125
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: cm-1-level-0
6+
data:
7+
APP_ENV: "production"
8+
APP_DEBUG: "false"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: cm-2-level-0
6+
data:
7+
APP_ENV: "production"
8+
APP_DEBUG: "false"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"apiVersion": "v1",
3+
"kind": "ConfigMap",
4+
"metadata": {
5+
"name": "cm-3-level-0"
6+
},
7+
"data": {
8+
"APP_ENV": "production",
9+
"APP_DEBUG": "false"
10+
}
11+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: cm-1-level-1
6+
namespace: kubectl-envsubst-plain-combined
7+
data:
8+
APP_ENV: "production"
9+
APP_DEBUG: "false"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"apiVersion": "v1",
3+
"kind": "ConfigMap",
4+
"metadata": {
5+
"name": "cm-2-level-1"
6+
},
7+
"data": {
8+
"APP_ENV": "production",
9+
"APP_DEBUG": "false"
10+
}
11+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: cm-1-level-2
6+
namespace: kubectl-envsubst-plain-combined
7+
data:
8+
APP_ENV: "production"
9+
APP_DEBUG: "false"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"apiVersion": "v1",
3+
"kind": "ConfigMap",
4+
"metadata": {
5+
"name": "cm-2-level-2"
6+
},
7+
"data": {
8+
"APP_ENV": "production",
9+
"APP_DEBUG": "false"
10+
}
11+
}

integration/plain_recursive_test.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package integration
2+
3+
import (
4+
"os"
5+
"os/exec"
6+
"strings"
7+
"testing"
8+
)
9+
10+
func TestEnvsubstIntegration_NoSubst_Recursive(t *testing.T) {
11+
12+
if os.Getenv(integrationTestEnv) != integrationTestFlag {
13+
t.Log("integration test was skipped due to configuration")
14+
return
15+
}
16+
17+
printEnvsubstVersionInfo(t)
18+
19+
namespaceName := "kubectl-envsubst-plain-recursive"
20+
createNs(t, namespaceName)
21+
22+
// Setup context
23+
setContextNs(t, namespaceName)
24+
25+
// Run kubectl-envsubst
26+
27+
cmdEnvsubstApply := exec.Command("kubectl",
28+
"envsubst",
29+
"apply",
30+
"-f",
31+
"immutable_data/resolve/plain-recursive",
32+
"--recursive")
33+
34+
output, err := cmdEnvsubstApply.CombinedOutput()
35+
stringOutput := string(output)
36+
if err != nil {
37+
t.Fatalf("Failed to run kubectl envsubst: %v, output: %s", err, stringOutput)
38+
}
39+
t.Logf("\n%s\n", strings.TrimSpace(stringOutput))
40+
41+
expectResources := []string{
42+
"cm-1-level-0",
43+
"cm-2-level-0",
44+
"cm-3-level-0",
45+
"cm-1-level-1",
46+
"cm-2-level-1",
47+
"cm-1-level-2",
48+
"cm-2-level-2",
49+
}
50+
51+
for _, er := range expectResources {
52+
expectedOutput := strings.Contains(stringOutput, er)
53+
if !expectedOutput {
54+
t.Errorf("Expected substituted output to contain '%s', got %s", er, stringOutput)
55+
}
56+
}
57+
58+
}

0 commit comments

Comments
 (0)