MCPcopy
hub / github.com/helm/helm / TestLoadArchive

Function TestLoadArchive

pkg/chart/loader/load_test.go:79–186  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

77}
78
79func TestLoadArchive(t *testing.T) {
80 testCases := []struct {
81 name string
82 chartName string
83 apiVersion string
84 extraFiles map[string][]byte
85 inputReader io.Reader
86 expectedChart chart.Charter
87 expectedError string
88 createChartYaml bool
89 }{
90 {
91 name: "valid v2 chart archive",
92 chartName: "mychart-v2",
93 apiVersion: c2.APIVersionV2,
94 extraFiles: map[string][]byte{"templates/config.yaml": []byte("key: value")},
95 expectedChart: &c2.Chart{
96 Metadata: &c2.Metadata{APIVersion: c2.APIVersionV2, Name: "mychart-v2", Version: "0.1.0", Description: "A test chart"},
97 },
98 createChartYaml: true,
99 },
100 {
101 name: "valid v3 chart archive",
102 chartName: "mychart-v3",
103 apiVersion: c3.APIVersionV3,
104 extraFiles: map[string][]byte{"templates/config.yaml": []byte("key: value")},
105 expectedChart: &c3.Chart{
106 Metadata: &c3.Metadata{APIVersion: c3.APIVersionV3, Name: "mychart-v3", Version: "0.1.0", Description: "A test chart"},
107 },
108 createChartYaml: true,
109 },
110 {
111 name: "invalid gzip header",
112 inputReader: bytes.NewBufferString("not a gzip file"),
113 expectedError: "stream does not appear to be a valid chart file (details: gzip: invalid header)",
114 },
115 {
116 name: "archive without Chart.yaml",
117 chartName: "no-chart-yaml",
118 apiVersion: c2.APIVersionV2, // This will be ignored as Chart.yaml is missing
119 extraFiles: map[string][]byte{"values.yaml": []byte("foo: bar")},
120 expectedError: "unable to detect chart version, no Chart.yaml found",
121 createChartYaml: false,
122 },
123 {
124 name: "archive with malformed Chart.yaml",
125 chartName: "malformed-chart-yaml",
126 apiVersion: c2.APIVersionV2,
127 extraFiles: map[string][]byte{"Chart.yaml": []byte("apiVersion: v2\nname: mychart\nversion: 0.1.0\ndescription: A test chart\ninvalid: :")},
128 expectedError: "cannot load Chart.yaml: error converting YAML to JSON: yaml: line 5: mapping values are not allowed in this context",
129 createChartYaml: false,
130 },
131 {
132 name: "unsupported API version",
133 chartName: "unsupported-api",
134 apiVersion: "v99",
135 expectedError: "unsupported chart version",
136 createChartYaml: true,

Callers

nothing calls this directly

Calls 7

NameMethod · 0.95
createChartArchiveFunction · 0.85
ContainsMethod · 0.80
FatalfMethod · 0.80
LoadArchiveFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…