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

Function CreateTempFile

codegen/testing.go:76–87  ·  view source on GitHub ↗

CreateTempFile creates a temporary file and writes the given content. It is used only for testing.

(t *testing.T, content string)

Source from the content-addressed store, hash-verified

74// CreateTempFile creates a temporary file and writes the given content.
75// It is used only for testing.
76func CreateTempFile(t *testing.T, content string) string {
77 t.Helper()
78 f, err := os.CreateTemp("", "")
79 require.NoError(t, err)
80 _, err = f.WriteString(content)
81 if err != nil {
82 require.NoError(t, os.Remove(f.Name()))
83 t.Fatal(err)
84 }
85 require.NoError(t, f.Close())
86 return f.Name()
87}

Callers 3

TestProtoFilesFunction · 0.92
TestMessageDefSectionFunction · 0.92

Calls 3

RemoveMethod · 0.80
NameMethod · 0.65
CloseMethod · 0.45

Tested by 3

TestProtoFilesFunction · 0.74
TestMessageDefSectionFunction · 0.74