Skip to content

add tests for lib/template funcmap helpers - #683

Merged
gianlucam76 merged 2 commits into
projectsveltos:mainfrom
magic-peach:test/template-funcmap-coverage
Sep 18, 2026
Merged

gianlucam76 merged 2 commits into
projectsveltos:mainfrom
magic-peach:test/template-funcmap-coverage

Conversation

@magic-peach

Copy link
Copy Markdown
Contributor

This repo has no PR template, so this is a plain factual description.

What changed

Added tests for the 8 template helper functions in ExtraFuncMap() in lib/template/funcmap.go: toYaml, fromYaml, fromYamlArray, toToml, fromToml, toJson, fromJson and fromJsonArray.

Why

None of these had any test coverage, including the error paths where a parse failure gets folded into the returned value instead of returned as a Go error, which matters since these are meant to be called from inside a template where a Go error return isn't available.

Testing

go build ./..., go vet ./lib/template/... and go test ./lib/template/... all pass, 12/12 specs.

gianlucam76
gianlucam76 previously approved these changes Sep 15, 2026

@gianlucam76 gianlucam76 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pushing this. LGTM

@gianlucam76

Copy link
Copy Markdown
Member

hi @magic-peach thank you for pushing this. Looks good. can you please push to "main" branch instead of "dev"? then we can merge it

toYaml, fromYaml, fromYamlArray, toToml, fromToml, toJson, fromJson and fromJsonArray had no coverage, including the error paths where a parse failure gets folded into the returned value instead of returned as a Go error, since these are meant to be called from inside a template.

Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
@magic-peach
magic-peach force-pushed the test/template-funcmap-coverage branch from bbca561 to c47f8f0 Compare September 15, 2026 13:57
@magic-peach
magic-peach changed the base branch from dev to main September 15, 2026 13:57
@magic-peach
magic-peach dismissed gianlucam76’s stale review September 15, 2026 13:57

The base branch was changed.

@magic-peach

magic-peach commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

@gianlucam76 Done, retargeted to main.

@gianlucam76

Copy link
Copy Markdown
Member

can you please fix the linting issues? thanks

Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
@gianlucam76
gianlucam76 merged commit ab255dd into projectsveltos:main Sep 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants