From e7114c0b304bd7b3c195e3446f21d6f7b6ff6571 Mon Sep 17 00:00:00 2001 From: James Payne Date: Mon, 28 Jun 2021 15:36:28 +0000 Subject: [PATCH] Add unit-tests to cover PR #9873 Tests expect the same YAML output as would be provided by the --debug --dry-run computed values Signed-off-by: James Payne --- cmd/helm/template_test.go | 15 +++ .../template-compute-values-overrides.txt | 107 ++++++++++++++++++ ...late-compute-values-subchart-overrides.txt | 107 ++++++++++++++++++ .../output/template-compute-values.txt | 107 ++++++++++++++++++ 4 files changed, 336 insertions(+) create mode 100644 cmd/helm/testdata/output/template-compute-values-overrides.txt create mode 100644 cmd/helm/testdata/output/template-compute-values-subchart-overrides.txt create mode 100644 cmd/helm/testdata/output/template-compute-values.txt diff --git a/cmd/helm/template_test.go b/cmd/helm/template_test.go index 30ee2722b..237d88a0f 100644 --- a/cmd/helm/template_test.go +++ b/cmd/helm/template_test.go @@ -131,6 +131,21 @@ func TestTemplateCmd(t *testing.T) { cmd: fmt.Sprintf(`template '%s' --skip-tests`, chartPath), golden: "output/template-skip-tests.txt", }, + { + name: "template compute-values", + cmd: fmt.Sprintf(`template '%s' --computed-values`, chartPath), + golden: "output/template-compute-values.txt", + }, + { + name: "template compute-values-overrides", + cmd: fmt.Sprintf(`template '%s' --computed-values --set service.name=apache`, chartPath), + golden: "output/template-compute-values-overrides.txt", + }, + { + name: "template compute-values-subchart-with-overrides", + cmd: fmt.Sprintf(`template '%s' --computed-values --set subcharta.service.name=nginx`, chartPath), + golden: "output/template-compute-values-subchart-overrides.txt", + }, } runTestCmd(t, tests) } diff --git a/cmd/helm/testdata/output/template-compute-values-overrides.txt b/cmd/helm/testdata/output/template-compute-values-overrides.txt new file mode 100644 index 000000000..bb0448719 --- /dev/null +++ b/cmd/helm/testdata/output/template-compute-values-overrides.txt @@ -0,0 +1,107 @@ +SC1data: + SC1bool: true + SC1extra1: 11 + SC1float: 3.14 + SC1int: 100 + SC1string: dollywood +SCBexported1A: + SC1extra7: true + SCBexported1B: 1965 +exports: + SC1exported1: + global: + SC1exported2: + all: + SC1exported3: SC1expstr + SCBexported2: + SCBexported2A: blaster +imported-chartA: + SC1extra2: 1.337 + SCAbool: false + SCAfloat: 3.1 + SCAint: 55 + SCAnested1: + SCAnested2: true + SCAstring: jabba +imported-chartA-B: + SC1extra5: tiller + SCAbool: false + SCAfloat: 3.1 + SCAint: 55 + SCAnested1: + SCAnested2: true + SCAstring: jabba + SCBbool: true + SCBfloat: 7.77 + SCBint: 33 + SCBstring: boba +imported-chartB: + SCBbool: true + SCBfloat: 7.77 + SCBint: 33 + SCBstring: boba +overridden-chartA: + SC1extra3: true + SCAbool: true + SCAfloat: 3.14 + SCAint: 100 + SCAnested1: + SCAnested2: true + SCAstring: jabbathehut +overridden-chartA-B: + SC1extra6: 77 + SCAbool: true + SCAextra1: 23 + SCAfloat: 3.33 + SCAint: 555 + SCAstring: wormwood + SCBbool: true + SCBextra1: 13 + SCBfloat: 0.25 + SCBint: 98 + SCBstring: murkwood +service: + externalPort: 80 + internalPort: 80 + name: apache + type: ClusterIP +subcharta: + SCAdata: + SCAbool: false + SCAfloat: 3.1 + SCAint: 55 + SCAnested1: + SCAnested2: true + SCAstring: jabba + global: {} + service: + externalPort: 80 + internalPort: 80 + name: apache + type: ClusterIP +subchartb: + SCBdata: + SCBbool: true + SCBfloat: 7.77 + SCBint: 33 + SCBstring: boba + exports: + SCBexported1: + SCBexported1A: + SCBexported1B: 1965 + SCBexported2: + SCBexported2A: blaster + global: + kolla: + nova: + api: + all: + port: 8774 + metadata: + all: + port: 8775 + service: + externalPort: 80 + internalPort: 80 + name: nginx + type: ClusterIP diff --git a/cmd/helm/testdata/output/template-compute-values-subchart-overrides.txt b/cmd/helm/testdata/output/template-compute-values-subchart-overrides.txt new file mode 100644 index 000000000..02ae9c254 --- /dev/null +++ b/cmd/helm/testdata/output/template-compute-values-subchart-overrides.txt @@ -0,0 +1,107 @@ +SC1data: + SC1bool: true + SC1extra1: 11 + SC1float: 3.14 + SC1int: 100 + SC1string: dollywood +SCBexported1A: + SC1extra7: true + SCBexported1B: 1965 +exports: + SC1exported1: + global: + SC1exported2: + all: + SC1exported3: SC1expstr + SCBexported2: + SCBexported2A: blaster +imported-chartA: + SC1extra2: 1.337 + SCAbool: false + SCAfloat: 3.1 + SCAint: 55 + SCAnested1: + SCAnested2: true + SCAstring: jabba +imported-chartA-B: + SC1extra5: tiller + SCAbool: false + SCAfloat: 3.1 + SCAint: 55 + SCAnested1: + SCAnested2: true + SCAstring: jabba + SCBbool: true + SCBfloat: 7.77 + SCBint: 33 + SCBstring: boba +imported-chartB: + SCBbool: true + SCBfloat: 7.77 + SCBint: 33 + SCBstring: boba +overridden-chartA: + SC1extra3: true + SCAbool: true + SCAfloat: 3.14 + SCAint: 100 + SCAnested1: + SCAnested2: true + SCAstring: jabbathehut +overridden-chartA-B: + SC1extra6: 77 + SCAbool: true + SCAextra1: 23 + SCAfloat: 3.33 + SCAint: 555 + SCAstring: wormwood + SCBbool: true + SCBextra1: 13 + SCBfloat: 0.25 + SCBint: 98 + SCBstring: murkwood +service: + externalPort: 80 + internalPort: 80 + name: nginx + type: ClusterIP +subcharta: + SCAdata: + SCAbool: false + SCAfloat: 3.1 + SCAint: 55 + SCAnested1: + SCAnested2: true + SCAstring: jabba + global: {} + service: + externalPort: 80 + internalPort: 80 + name: nginx + type: ClusterIP +subchartb: + SCBdata: + SCBbool: true + SCBfloat: 7.77 + SCBint: 33 + SCBstring: boba + exports: + SCBexported1: + SCBexported1A: + SCBexported1B: 1965 + SCBexported2: + SCBexported2A: blaster + global: + kolla: + nova: + api: + all: + port: 8774 + metadata: + all: + port: 8775 + service: + externalPort: 80 + internalPort: 80 + name: nginx + type: ClusterIP diff --git a/cmd/helm/testdata/output/template-compute-values.txt b/cmd/helm/testdata/output/template-compute-values.txt new file mode 100644 index 000000000..6a15f3999 --- /dev/null +++ b/cmd/helm/testdata/output/template-compute-values.txt @@ -0,0 +1,107 @@ +SC1data: + SC1bool: true + SC1extra1: 11 + SC1float: 3.14 + SC1int: 100 + SC1string: dollywood +SCBexported1A: + SC1extra7: true + SCBexported1B: 1965 +exports: + SC1exported1: + global: + SC1exported2: + all: + SC1exported3: SC1expstr + SCBexported2: + SCBexported2A: blaster +imported-chartA: + SC1extra2: 1.337 + SCAbool: false + SCAfloat: 3.1 + SCAint: 55 + SCAnested1: + SCAnested2: true + SCAstring: jabba +imported-chartA-B: + SC1extra5: tiller + SCAbool: false + SCAfloat: 3.1 + SCAint: 55 + SCAnested1: + SCAnested2: true + SCAstring: jabba + SCBbool: true + SCBfloat: 7.77 + SCBint: 33 + SCBstring: boba +imported-chartB: + SCBbool: true + SCBfloat: 7.77 + SCBint: 33 + SCBstring: boba +overridden-chartA: + SC1extra3: true + SCAbool: true + SCAfloat: 3.14 + SCAint: 100 + SCAnested1: + SCAnested2: true + SCAstring: jabbathehut +overridden-chartA-B: + SC1extra6: 77 + SCAbool: true + SCAextra1: 23 + SCAfloat: 3.33 + SCAint: 555 + SCAstring: wormwood + SCBbool: true + SCBextra1: 13 + SCBfloat: 0.25 + SCBint: 98 + SCBstring: murkwood +service: + externalPort: 80 + internalPort: 80 + name: nginx + type: ClusterIP +subcharta: + SCAdata: + SCAbool: false + SCAfloat: 3.1 + SCAint: 55 + SCAnested1: + SCAnested2: true + SCAstring: jabba + global: {} + service: + externalPort: 80 + internalPort: 80 + name: apache + type: ClusterIP +subchartb: + SCBdata: + SCBbool: true + SCBfloat: 7.77 + SCBint: 33 + SCBstring: boba + exports: + SCBexported1: + SCBexported1A: + SCBexported1B: 1965 + SCBexported2: + SCBexported2A: blaster + global: + kolla: + nova: + api: + all: + port: 8774 + metadata: + all: + port: 8775 + service: + externalPort: 80 + internalPort: 80 + name: nginx + type: ClusterIP