From b9a5bd8a9c8c586529b808435a6de948fec252ec Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Mon, 22 Jan 2024 09:46:30 -0800 Subject: [PATCH] Add test for sha256sum function --- pkg/templatelib/lib_example_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/templatelib/lib_example_test.go b/pkg/templatelib/lib_example_test.go index 53a4495a..2fd7b861 100644 --- a/pkg/templatelib/lib_example_test.go +++ b/pkg/templatelib/lib_example_test.go @@ -219,3 +219,17 @@ func Example_getenv() { // BAZ: foobar // FOOBARBAZ } + +func Example_sha256sum() { + tmpl, err := template.New("sha256sum").Funcs(templatelib.FuncMap).Parse(` + {{- "Hello World!" | sha256sum -}} + `) + + err = tmpl.Execute(os.Stdout, nil) + if err != nil { + panic(err) + } + + // Output: + // 7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069 +}