github.com/liuming-dev/helm@v3.0.0-beta.3+incompatible/cmd/helm/install_test.go (about) 1 /* 2 Copyright The Helm Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package main 18 19 import ( 20 "testing" 21 ) 22 23 func TestInstall(t *testing.T) { 24 tests := []cmdTestCase{ 25 // Install, base case 26 { 27 name: "basic install", 28 cmd: "install aeneas testdata/testcharts/empty --namespace default", 29 golden: "output/install.txt", 30 }, 31 32 // Install, values from cli 33 { 34 name: "install with values", 35 cmd: "install virgil testdata/testcharts/alpine --set test.Name=bar", 36 golden: "output/install-with-values.txt", 37 }, 38 // Install, values from cli via multiple --set 39 { 40 name: "install with multiple values", 41 cmd: "install virgil testdata/testcharts/alpine --set test.Color=yellow --set test.Name=banana", 42 golden: "output/install-with-multiple-values.txt", 43 }, 44 // Install, values from yaml 45 { 46 name: "install with values file", 47 cmd: "install virgil testdata/testcharts/alpine -f testdata/testcharts/alpine/extra_values.yaml", 48 golden: "output/install-with-values-file.txt", 49 }, 50 // Install, no hooks 51 { 52 name: "install without hooks", 53 cmd: "install aeneas testdata/testcharts/alpine --no-hooks --set test.Name=hello", 54 golden: "output/install-no-hooks.txt", 55 }, 56 // Install, values from multiple yaml 57 { 58 name: "install with values", 59 cmd: "install virgil testdata/testcharts/alpine -f testdata/testcharts/alpine/extra_values.yaml -f testdata/testcharts/alpine/more_values.yaml", 60 golden: "output/install-with-multiple-values-files.txt", 61 }, 62 // Install, no charts 63 { 64 name: "install with no chart specified", 65 cmd: "install", 66 golden: "output/install-no-args.txt", 67 wantError: true, 68 }, 69 // Install, re-use name 70 { 71 name: "install and replace release", 72 cmd: "install aeneas testdata/testcharts/empty --replace", 73 golden: "output/install-and-replace.txt", 74 }, 75 // Install, with timeout 76 { 77 name: "install with a timeout", 78 cmd: "install foobar testdata/testcharts/empty --timeout 120s", 79 golden: "output/install-with-timeout.txt", 80 }, 81 // Install, with wait 82 { 83 name: "install with a wait", 84 cmd: "install apollo testdata/testcharts/empty --wait", 85 golden: "output/install-with-wait.txt", 86 }, 87 // Install, using the name-template 88 { 89 name: "install with name-template", 90 cmd: "install testdata/testcharts/empty --name-template '{{upper \"foobar\"}}'", 91 golden: "output/install-name-template.txt", 92 }, 93 // Install, perform chart verification along the way. 94 { 95 name: "install with verification, missing provenance", 96 cmd: "install bogus testdata/testcharts/compressedchart-0.1.0.tgz --verify --keyring testdata/helm-test-key.pub", 97 wantError: true, 98 }, 99 { 100 name: "install with verification, directory instead of file", 101 cmd: "install bogus testdata/testcharts/signtest --verify --keyring testdata/helm-test-key.pub", 102 wantError: true, 103 }, 104 { 105 name: "install with verification, valid", 106 cmd: "install signtest testdata/testcharts/signtest-0.1.0.tgz --verify --keyring testdata/helm-test-key.pub", 107 }, 108 // Install, chart with missing dependencies in /charts 109 { 110 name: "install chart with missing dependencies", 111 cmd: "install nodeps testdata/testcharts/chart-missing-deps", 112 wantError: true, 113 }, 114 // Install, chart with bad dependencies in Chart.yaml in /charts 115 { 116 name: "install chart with bad dependencies in Chart.yaml", 117 cmd: "install badreq testdata/testcharts/chart-bad-requirements", 118 wantError: true, 119 }, 120 // Install, chart with library chart dependency 121 { 122 name: "install chart with library chart dependency", 123 cmd: "install withlibchartp testdata/testcharts/chart-with-lib-dep", 124 }, 125 // Install, library chart 126 { 127 name: "install library chart", 128 cmd: "install libchart testdata/testcharts/lib-chart", 129 wantError: true, 130 golden: "output/template-lib-chart.txt", 131 }, 132 // Install, chart with bad type 133 { 134 name: "install chart with bad type", 135 cmd: "install badtype testdata/testcharts/chart-bad-type", 136 wantError: true, 137 golden: "output/install-chart-bad-type.txt", 138 }, 139 // Install, values from yaml, schematized 140 { 141 name: "install with schema file", 142 cmd: "install schema testdata/testcharts/chart-with-schema", 143 golden: "output/schema.txt", 144 }, 145 // Install, values from yaml, schematized with errors 146 { 147 name: "install with schema file, with errors", 148 cmd: "install schema testdata/testcharts/chart-with-schema-negative", 149 wantError: true, 150 golden: "output/schema-negative.txt", 151 }, 152 // Install, values from yaml, extra values from yaml, schematized with errors 153 { 154 name: "install with schema file, extra values from yaml, with errors", 155 cmd: "install schema testdata/testcharts/chart-with-schema -f testdata/testcharts/chart-with-schema/extra-values.yaml", 156 wantError: true, 157 golden: "output/schema-negative.txt", 158 }, 159 // Install, values from yaml, extra values from cli, schematized with errors 160 { 161 name: "install with schema file, extra values from cli, with errors", 162 cmd: "install schema testdata/testcharts/chart-with-schema --set age=-5", 163 wantError: true, 164 golden: "output/schema-negative-cli.txt", 165 }, 166 // Install with subchart, values from yaml, schematized with errors 167 { 168 name: "install with schema file and schematized subchart, with errors", 169 cmd: "install schema testdata/testcharts/chart-with-schema-and-subchart", 170 wantError: true, 171 golden: "output/subchart-schema-negative.txt", 172 }, 173 // Install with subchart, values from yaml, extra values from cli, schematized with errors 174 { 175 name: "install with schema file and schematized subchart, extra values from cli", 176 cmd: "install schema testdata/testcharts/chart-with-schema-and-subchart --set lastname=doe --set subchart-with-schema.age=25", 177 golden: "output/subchart-schema-cli.txt", 178 }, 179 // Install with subchart, values from yaml, extra values from cli, schematized with errors 180 { 181 name: "install with schema file and schematized subchart, extra values from cli, with errors", 182 cmd: "install schema testdata/testcharts/chart-with-schema-and-subchart --set lastname=doe --set subchart-with-schema.age=-25", 183 wantError: true, 184 golden: "output/subchart-schema-cli-negative.txt", 185 }, 186 } 187 188 runTestActionCmd(t, tests) 189 }