MCPcopy
hub / github.com/ory/keto / createFile

Function createFile

internal/driver/config/provider_test.go:29–48  ·  view source on GitHub ↗

createFile writes the content to a temporary file, returning the path. Good for testing config files.

(t *testing.T, content string)

Source from the content-addressed store, hash-verified

27// createFile writes the content to a temporary file, returning the path.
28// Good for testing config files.
29func createFile(t *testing.T, content string) (path string) {
30 t.Helper()
31
32 f, err := os.CreateTemp(t.TempDir(), "config-*.yaml")
33 if err != nil {
34 t.Fatal(err)
35 }
36
37 t.Cleanup(func() { _ = os.Remove(f.Name()) })
38
39 n, err := f.WriteString(content)
40 if err != nil {
41 t.Fatal(err)
42 }
43 if n != len(content) {
44 t.Fatal("failed to write the complete content")
45 }
46
47 return f.Name()
48}
49
50// createFileF writes the content format string with the applied args to a
51// temporary file, returning the path. Good for testing config files.

Callers 4

createFileFFunction · 0.70

Calls 1

NameMethod · 0.45

Tested by

no test coverage detected