MCPcopy Create free account
hub / github.com/Azure/draft / TestRenderHelmChart_Valid

Function TestRenderHelmChart_Valid

pkg/safeguards/preprocessing/preprocessing_test.go:13–40  ·  view source on GitHub ↗

Test rendering a valid Helm chart with no subcharts and three templates

(t *testing.T)

Source from the content-addressed store, hash-verified

11
12// Test rendering a valid Helm chart with no subcharts and three templates
13func TestRenderHelmChart_Valid(t *testing.T) {
14 var opt chartutil.ReleaseOptions
15
16 manifestFiles, err := RenderHelmChart(false, consts.ChartPath, opt)
17 assert.Nil(t, err)
18
19 // Check that the output directory exists and contains expected files
20 expectedFiles := make(map[string][]byte)
21 expectedFiles["deployment.yaml"] = getManifestAsBytes(t, "../tests/testmanifests/expecteddeployment.yaml")
22 expectedFiles["service.yaml"] = getManifestAsBytes(t, "../tests/testmanifests/expectedservice.yaml")
23 expectedFiles["ingress.yaml"] = getManifestAsBytes(t, "../tests/testmanifests/expectedingress.yaml")
24
25 for i, writtenManifestFile := range manifestFiles {
26 writtenFileName := manifestFiles[i].Name
27 expectedYaml := bytes.TrimSpace(expectedFiles[writtenFileName])
28 assert.Equal(t, bytes.TrimSpace(writtenManifestFile.ManifestContent), expectedYaml)
29 }
30
31 // Test by giving file directly
32 manifestFiles, err = RenderHelmChart(true, consts.DirectPath_ToValidChart, opt)
33 assert.Nil(t, err)
34
35 for i, writtenManifestFile := range manifestFiles {
36 writtenFileName := manifestFiles[i].Name
37 expectedYaml := bytes.TrimSpace(expectedFiles[writtenFileName])
38 assert.Equal(t, bytes.TrimSpace(writtenManifestFile.ManifestContent), expectedYaml)
39 }
40}
41
42// Test rendering a valid Helm chart with no subcharts and three templates, using command line flags
43func TestRenderHelmChartWithFlags_Valid(t *testing.T) {

Callers

nothing calls this directly

Calls 2

RenderHelmChartFunction · 0.85
getManifestAsBytesFunction · 0.85

Tested by

no test coverage detected