MCPcopy Index your code
hub / github.com/smallstep/cli / newFile

Function newFile

utils/read_test.go:31–40  ·  view source on GitHub ↗

Returns a temp file and a cleanup function to delete it.

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

Source from the content-addressed store, hash-verified

29
30// Returns a temp file and a cleanup function to delete it.
31func newFile(t *testing.T, data []byte) (file *os.File, cleanup func()) {
32 f, err := os.CreateTemp(t.TempDir(), "utils-read-test")
33 require.NoError(t, err)
34 // write to temp file and reset read cursor to beginning of file
35 _, err = f.Write(data)
36 require.NoError(t, err)
37 _, err = f.Seek(0, io.SeekStart)
38 require.NoError(t, err)
39 return f, func() { os.Remove(f.Name()) }
40}
41
42func TestFileExists(t *testing.T) {
43 content := []byte("my file content")

Callers 6

TestFileExistsFunction · 0.85
TestReadFileFunction · 0.85
TestReadFileStdinFunction · 0.85
TestReadPasswordFromFileFunction · 0.85
TestReadInputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…