fix tests

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero 2025-02-04 19:47:40 +08:00 committed by Zubair Haque
parent 00d44c553f
commit c6d402c6a2
2 changed files with 0 additions and 46 deletions

View File

@ -33,7 +33,6 @@ func (r *desiredStateLoader) renderTemplatesToYamlWithEnv(baseDir, filename stri
}
func (r *desiredStateLoader) twoPassRenderTemplateToYaml(inherited, overrode *environment.Environment, baseDir, filename string, content []byte) (*bytes.Buffer, error) {
// try a first pass render. This will always succeed, but can produce a limited env
var phase string
r.logger.Debugf("%srendering starting for \"%s\": inherited=%v, overrode=%v", phase, filename, inherited, overrode)

View File

@ -197,51 +197,6 @@ releases:
}
}
// This test shows that a gotmpl reference will get rendered correctly
// even if the pre-render disables the readFile and exec functions.
// This does not apply to .gotmpl files, which is a nice side-effect.
func TestReadFromYaml_RenderTemplateWithGotmpl(t *testing.T) {
defaultValuesYamlGotmpl := `
releaseName: {{ readFile "nonIgnoredFile" }}
`
yamlContent := []byte(`
environments:
staging:
values:
- values.yaml.gotmpl
production:
{{ if (eq .Environment.Values.releaseName "release-a") }} # line 8
releases:
- name: a
chart: mychart1
{{ end }}
`)
files := map[string]string{
"/path/to/nonIgnoredFile": `release-a`,
"/path/to/values.yaml": defaultValuesYamlGotmpl,
}
r, _, _ := makeLoader(files, "staging")
rendered, _ := r.renderTemplatesToYaml("", "", yamlContent)
var state state.HelmState
err := yaml.Unmarshal(rendered.Bytes(), &state)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if len(state.Releases) != 1 {
t.Fatal("there should be 1 release")
}
if state.Releases[0].Name != "a" {
t.Fatal("release should have been declared")
}
}
func TestReadFromYaml_RenderTemplateWithNamespace(t *testing.T) {
yamlContent := []byte(`releases:
- name: {{ .Namespace }}-myrelease