MCPcopy Create free account
hub / github.com/canopyclimate/golive / TestBasicSerialization

Function TestBasicSerialization

internal/tmpl/tree_test.go:18–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestBasicSerialization(t *testing.T) {
19 root := tmpl.NewTree()
20 tree := root
21 tree.AppendDynamic("abc")
22 tree.AppendStatic("def")
23 tree = tree.AppendSub()
24 tree.AppendStatic("xyz")
25 buf := new(bytes.Buffer)
26 n, err := root.WriteTo(buf)
27 if err != nil {
28 t.Fatal(err)
29 }
30 if n != int64(buf.Len()) {
31 t.Fatalf("wrote %d but tracked %d", buf.Len(), n)
32 }
33 const want = `{"0":"abc","1":"xyz","s":["","def",""]}`
34 got := buf.String()
35 if want != got {
36 t.Fatalf("got %q want %q", got, want)
37 }
38}
39
40type dot = map[string]any
41

Callers

nothing calls this directly

Calls 7

WriteToMethod · 0.95
NewTreeFunction · 0.92
AppendDynamicMethod · 0.80
AppendStaticMethod · 0.80
AppendSubMethod · 0.80
LenMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected