aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/helm/helm_test.go
diff options
context:
space:
mode:
authorKonrad Bańka <k.banka@samsung.com>2020-11-12 09:13:37 +0100
committerKonrad Bańka <k.banka@samsung.com>2020-11-18 14:16:29 +0100
commit8c86f56defd56c5ea02eb6952ba4b852599100d5 (patch)
tree22914b5a493ffdff2f540354e38019869976cbcb /src/k8splugin/internal/helm/helm_test.go
parent0c352ef0d74d4b51a0fce5123b34a6753e8ab6a4 (diff)
Improve early-detection of empty template
Previous empty template detection pattern matched only against templates resolved to empty-or-whitespace-only files. This change makes it handle other case of empty yaml correctly, namely, yaml containing comments only. Issue-ID: MULTICLOUD-1252 Signed-off-by: Konrad Bańka <k.banka@samsung.com> Change-Id: I9132e167ec607c8a4a4ca5584141ed043c6ddd4f
Diffstat (limited to 'src/k8splugin/internal/helm/helm_test.go')
-rw-r--r--src/k8splugin/internal/helm/helm_test.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/k8splugin/internal/helm/helm_test.go b/src/k8splugin/internal/helm/helm_test.go
index 1e676c52..817bbaa3 100644
--- a/src/k8splugin/internal/helm/helm_test.go
+++ b/src/k8splugin/internal/helm/helm_test.go
@@ -155,6 +155,33 @@ func TestGenerateKubernetesArtifacts(t *testing.T) {
},
expectedError: "",
},
+ {
+ label: "Generate artifacts from multi-template and empty files v1",
+ chartPath: "../../mock_files/mock_charts/testchart3",
+ valueFiles: []string{},
+ values: []string{
+ "goingEmpty=false",
+ },
+ expectedHashMap: map[string]string{
+ "testchart3/templates/multi.yaml-2": "e24cbbefac2c2f700880b8fd041838f2dd48bbc1e099e7c1d2485ae7feb3da0d",
+ "testchart3/templates/multi.yaml-3": "592a8e5b2c35b8469aa45703a835bc00657bfe36b51eb08427a46e7d22fb1525",
+ },
+ expectedError: "",
+ },
+ {
+ label: "Generate artifacts from multi-template and empty files v2",
+ chartPath: "../../mock_files/mock_charts/testchart3",
+ valueFiles: []string{},
+ values: []string{
+ "goingEmpty=true",
+ },
+ expectedHashMap: map[string]string{
+ "testchart3/templates/multi.yaml-3": "e24cbbefac2c2f700880b8fd041838f2dd48bbc1e099e7c1d2485ae7feb3da0d",
+ "testchart3/templates/multi.yaml-4": "0bea01e65148584609ede5000c024241ba1c35b440b32ec0a4f7013015715bfe",
+ "testchart3/templates/multi.yaml-5": "6a5af22538c273b9d4a3156e3b6bb538c655041eae31e93db21a9e178f73ecf0",
+ },
+ expectedError: "",
+ },
}
h := sha256.New()
@@ -192,7 +219,7 @@ func TestGenerateKubernetesArtifacts(t *testing.T) {
}
}
if gotHash != expectedHash {
- t.Fatalf("Got unexpected hash for %s", f)
+ t.Fatalf("Got unexpected hash for %s: '%s'; expected: '%s'", f, gotHash, expectedHash)
}
}
}