MCPcopy Index your code
hub / github.com/coder/envbox / TmpDir

Function TmpDir

integration/integrationtest/os.go:13–27  ·  view source on GitHub ↗

TmpDir returns a subdirectory in /tmp that can be used for test files.

(t *testing.T)

Source from the content-addressed store, hash-verified

11
12// TmpDir returns a subdirectory in /tmp that can be used for test files.
13func TmpDir(t *testing.T) string {
14 // We use os.MkdirTemp as oposed to t.TempDir since the envbox container will
15 // chown some of the created directories here to root:root causing the cleanup
16 // function to fail once the test exits.
17 tmpdir, err := os.MkdirTemp("", strings.ReplaceAll(t.Name(), "/", "_"))
18 require.NoError(t, err)
19 t.Logf("using tmpdir %s", tmpdir)
20 t.Cleanup(func() {
21 if !t.Failed() {
22 // Could be useful in case of test failure.
23 _ = os.RemoveAll(tmpdir)
24 }
25 })
26 return tmpdir
27}
28
29func MkdirAll(t testing.TB, elem ...string) string {
30 t.Helper()

Callers 3

startEnvboxCmdFunction · 0.92
TestDockerFunction · 0.92
RunEnvboxFunction · 0.85

Calls

no outgoing calls

Tested by 2

startEnvboxCmdFunction · 0.74
TestDockerFunction · 0.74