Skip to content

Commit

Permalink
fix: adjust test to not require external chart
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesimpson36 committed Dec 3, 2024
1 parent 5e61b2f commit 15b8c31
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ func cleanupExecError(filename string, err error) error {
finalErrorString = finalErrorString + "\n" + i.location + " " + i.message
}

return fmt.Errorf("%s\n\n\n\nError: %s", finalErrorString, err.Error())
return fmt.Errorf("NEW ERROR FORMAT: \n%s\n\n\nORIGINAL ERROR:\n%s", finalErrorString, err.Error())
}

func sortTemplates(tpls map[string]renderable) []string {
Expand Down
28 changes: 19 additions & 9 deletions pkg/engine/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package engine
import (
"fmt"
"github.com/stretchr/testify/assert"
"helm.sh/helm/v3/pkg/chart/loader"
"path"
"strings"
"sync"
Expand Down Expand Up @@ -1303,21 +1302,32 @@ func TestRenderTplMissingKeyString(t *testing.T) {
}
}

func TestSometimesJesseJustBe(t *testing.T) {
c, _ := loader.Load("/home/jesse/code/camunda-platform-helm/charts/camunda-platform-8.5")
func TestNestedHelpersProducesMultilineStacktrace(t *testing.T) {
c := &chart.Chart{
Metadata: &chart.Metadata{Name: "NestedHelperFunctions"},
Templates: []*chart.File{
{Name: "templates/svc.yaml", Data: []byte(
`name: {{ include "nested_helper.name" . }}`,
)},
{Name: "templates/_helpers_1.tpl", Data: []byte(
`{{- define "nested_helper.name" -}}{{- include "common.names.get_name" . -}}{{- end -}}`,
)},
{Name: "charts/common/templates/_helpers_2.tpl", Data: []byte(
`{{- define "common.names.get_name" -}}{{- .Release.Name | trunc 63 | trimSuffix "-" -}}{{- end -}}`,
)},
},
}

v := chartutil.Values{}

v, _ := chartutil.ReadValuesFile("/home/jesse/code/helm/values.yaml")
val, _ := chartutil.CoalesceValues(c, v)
vals := map[string]interface{}{
"Values": val.AsMap(),
}
out, err := Render(c, vals)
_, err := Render(c, vals)

assert.NotNil(t, err)
if err != nil {
t.Errorf("Failed to render templates: %s", err)
}
assert.NotNil(t, out)
data := strings.TrimSpace(out["jesse-subchart-values-hacktest/charts/keycloak/templates/ingress.yaml"])
fmt.Println(data)
assert.NotEmpty(t, data)
}

0 comments on commit 15b8c31

Please sign in to comment.