MCPcopy
hub / github.com/helm/helm / TempFile

Function TempFile

internal/test/ensure/ensure.go:48–56  ·  view source on GitHub ↗

TempFile ensures a temp file for unit testing purposes. It returns the path to the directory (to which you will still need to join the filename) The returned directory is automatically removed when the test and all its subtests complete. tempdir := TempFile(t, "foo", []byte("bar")) filename :=

(t *testing.T, name string, data []byte)

Source from the content-addressed store, hash-verified

46// tempdir := TempFile(t, "foo", []byte("bar"))
47// filename := filepath.Join(tempdir, "foo")
48func TempFile(t *testing.T, name string, data []byte) string {
49 t.Helper()
50 path := t.TempDir()
51 filename := filepath.Join(path, name)
52 if err := os.WriteFile(filename, data, 0o755); err != nil {
53 t.Fatal(err)
54 }
55 return path
56}

Calls 3

HelperMethod · 0.80
FatalMethod · 0.80
WriteFileMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…