MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / TestEncodeGolden

Function TestEncodeGolden

internal/artifact/encode_test.go:60–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestEncodeGolden(t *testing.T) {
61 cases := []struct {
62 name string
63 artifact Artifact
64 golden string
65 }{
66 {"playbook", samplePlaybook(), "playbook.golden.md"},
67 {"convention", sampleConvention(), "convention.golden.md"},
68 }
69 for _, tc := range cases {
70 t.Run(tc.name, func(t *testing.T) {
71 got, err := Encode(tc.artifact)
72 if err != nil {
73 t.Fatalf("Encode: %v", err)
74 }
75 path := filepath.Join("testdata", tc.golden)
76 if *update {
77 if err := os.WriteFile(path, got, 0o644); err != nil {
78 t.Fatalf("write golden: %v", err)
79 }
80 return
81 }
82 want, err := os.ReadFile(path)
83 if err != nil {
84 t.Fatalf("read golden (run -update to create): %v", err)
85 }
86 if !bytes.Equal(got, want) {
87 t.Errorf("Encode output mismatch with %s\n--- got ---\n%s\n--- want ---\n%s", tc.golden, got, want)
88 }
89 })
90 }
91}
92
93func TestEncodeDeterministic(t *testing.T) {
94 for _, a := range []Artifact{samplePlaybook(), sampleConvention()} {

Callers

nothing calls this directly

Calls 5

samplePlaybookFunction · 0.85
sampleConventionFunction · 0.85
EncodeFunction · 0.85
RunMethod · 0.80
JoinMethod · 0.80

Tested by

no test coverage detected