MCPcopy Create free account
hub / github.com/goadesign/goa / compareOrUpdateGolden

Function compareOrUpdateGolden

codegen/example/example_server_test.go:26–39  ·  view source on GitHub ↗
(t *testing.T, code, golden string)

Source from the content-addressed store, hash-verified

24}
25
26func compareOrUpdateGolden(t *testing.T, code, golden string) {
27 t.Helper()
28 if updateGolden {
29 require.NoError(t, os.MkdirAll(filepath.Dir(golden), 0750))
30 require.NoError(t, os.WriteFile(golden, []byte(code), 0640))
31 return
32 }
33 data, err := os.ReadFile(golden)
34 require.NoError(t, err)
35 if runtime.GOOS == "windows" {
36 data = bytes.ReplaceAll(data, []byte("\r\n"), []byte("\n"))
37 }
38 assert.Equal(t, string(data), code)
39}
40
41func TestExampleServerFiles(t *testing.T) {
42 cases := []struct {

Callers 2

TestExampleServerFilesFunction · 0.70
TestExampleCLIFilesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected