MCPcopy
hub / github.com/pocketbase/pocketbase / TestRegistryAddFuncs

Function TestRegistryAddFuncs

tools/template/registry_test.go:37–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestRegistryAddFuncs(t *testing.T) {
38 r := NewRegistry()
39
40 r.AddFuncs(map[string]any{
41 "test": func(a string) string { return a + "-TEST" },
42 })
43
44 checkRegistryFuncs(t, r, "raw", "test")
45
46 result, err := r.LoadString(`{{.|test}}`).Render("example")
47 if err != nil {
48 t.Fatalf("Unexpected Render() error, got %v", err)
49 }
50
51 expected := "example-TEST"
52 if result != expected {
53 t.Fatalf("Expected Render() result %q, got %q", expected, result)
54 }
55}
56
57func TestRegistryLoadFiles(t *testing.T) {
58 r := NewRegistry()

Callers

nothing calls this directly

Calls 5

AddFuncsMethod · 0.95
LoadStringMethod · 0.95
NewRegistryFunction · 0.85
checkRegistryFuncsFunction · 0.85
RenderMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…