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

Function CreateTempFile

expr/testing.go:52–67  ·  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

50// CreateTempFile creates a temporary file and writes the given content.
51// It is used only for testing.
52func CreateTempFile(t *testing.T, content string) string {
53 t.Helper()
54 f, err := os.CreateTemp("", "")
55 if err != nil {
56 t.Fatal(err)
57 }
58 _, err = f.WriteString(content)
59 if err != nil {
60 _ = os.Remove(f.Name())
61 t.Fatal(err)
62 }
63 if err := f.Close(); err != nil {
64 t.Fatal(err)
65 }
66 return f.Name()
67}
68
69// ResetDSL resets the global expression state for testing and initializes
70// a default API. This function should be called before running any DSL that

Callers

nothing calls this directly

Calls 3

RemoveMethod · 0.80
NameMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected