github.com/ryanhartje/helm@v3.0.0-beta.3+incompatible/cmd/helm/template_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  	"fmt"
    21  	"path/filepath"
    22  	"testing"
    23  )
    24  
    25  var chartPath = "./../../pkg/chartutil/testdata/subpop/charts/subchart1"
    26  
    27  func TestTemplateCmd(t *testing.T) {
    28  	tests := []cmdTestCase{
    29  		{
    30  			name:   "check name",
    31  			cmd:    fmt.Sprintf("template '%s'", chartPath),
    32  			golden: "output/template.txt",
    33  		},
    34  		{
    35  			name:   "check set name",
    36  			cmd:    fmt.Sprintf("template '%s' --set service.name=apache", chartPath),
    37  			golden: "output/template-set.txt",
    38  		},
    39  		{
    40  			name:   "check values files",
    41  			cmd:    fmt.Sprintf("template '%s' --values '%s'", chartPath, filepath.Join(chartPath, "/charts/subchartA/values.yaml")),
    42  			golden: "output/template-values-files.txt",
    43  		},
    44  		{
    45  			name:   "check name template",
    46  			cmd:    fmt.Sprintf(`template '%s' --name-template='foobar-{{ b64enc "abc" }}-baz'`, chartPath),
    47  			golden: "output/template-name-template.txt",
    48  		},
    49  		{
    50  			name:      "check no args",
    51  			cmd:       "template",
    52  			wantError: true,
    53  			golden:    "output/template-no-args.txt",
    54  		},
    55  		{
    56  			name:      "check library chart",
    57  			cmd:       fmt.Sprintf("template '%s'", "testdata/testcharts/lib-chart"),
    58  			wantError: true,
    59  			golden:    "output/template-lib-chart.txt",
    60  		},
    61  		{
    62  			name:      "check chart bad type",
    63  			cmd:       fmt.Sprintf("template '%s'", "testdata/testcharts/chart-bad-type"),
    64  			wantError: true,
    65  			golden:    "output/install-chart-bad-type.txt",
    66  		},
    67  		{
    68  			name:   "check chart with dependency which is an app chart acting as a library chart",
    69  			cmd:    fmt.Sprintf("template '%s'", "testdata/testcharts/chart-with-template-lib-dep"),
    70  			golden: "output/template-chart-with-template-lib-dep.txt",
    71  		},
    72  		{
    73  			name:   "check chart with dependency which is an app chart archive acting as a library chart",
    74  			cmd:    fmt.Sprintf("template '%s'", "testdata/testcharts/chart-with-template-lib-archive-dep"),
    75  			golden: "output/template-chart-with-template-lib-archive-dep.txt",
    76  		},
    77  	}
    78  	runTestCmd(t, tests)
    79  }