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

Function FormatTestCode

codegen/testing.go:66–72  ·  view source on GitHub ↗

FormatTestCode formats the given Go code. The code must correspond to the content of a valid Go source file (i.e. start with "package")

(t *testing.T, code string)

Source from the content-addressed store, hash-verified

64// FormatTestCode formats the given Go code. The code must correspond to the
65// content of a valid Go source file (i.e. start with "package")
66func FormatTestCode(t *testing.T, code string) string {
67 t.Helper()
68 // Process the code in memory without creating a temp file
69 formatted, err := finalizeGoSource("test.go", []byte(code))
70 require.NoError(t, err)
71 return strings.Join(strings.Split(string(formatted), "\n")[2:], "\n")
72}
73
74// CreateTempFile creates a temporary file and writes the given content.
75// It is used only for testing.

Callers 15

TestClientTypesFunction · 0.92
TestClientTypeFilesFunction · 0.92
TestExampleServerFilesFunction · 0.92
TestExampleCLIFilesFunction · 0.92
TestCookieAPIKeySecurityFunction · 0.92
renderClientTypesCodeFunction · 0.92
TestServerTypesFunction · 0.92
TestClientTypeFilesFunction · 0.92
TestExampleServerFilesFunction · 0.92
TestProtoBufTransformFunction · 0.92
TestExampleCLIFilesFunction · 0.92
TestServerTypeFilesFunction · 0.92

Calls 1

finalizeGoSourceFunction · 0.85

Tested by 15

TestClientTypesFunction · 0.74
TestClientTypeFilesFunction · 0.74
TestExampleServerFilesFunction · 0.74
TestExampleCLIFilesFunction · 0.74
TestCookieAPIKeySecurityFunction · 0.74
renderClientTypesCodeFunction · 0.74
TestServerTypesFunction · 0.74
TestClientTypeFilesFunction · 0.74
TestExampleServerFilesFunction · 0.74
TestProtoBufTransformFunction · 0.74
TestExampleCLIFilesFunction · 0.74
TestServerTypeFilesFunction · 0.74