MCPcopy
hub / github.com/kopia/kopia / TempDirectory

Function TempDirectory

internal/testutil/tmpdir.go:54–71  ·  view source on GitHub ↗

TempDirectory returns an interesting temporary directory and cleans it up before test completes.

(tb testing.TB)

Source from the content-addressed store, hash-verified

52// TempDirectory returns an interesting temporary directory and cleans it up before test
53// completes.
54func TempDirectory(tb testing.TB) string {
55 tb.Helper()
56
57 d, err := GetInterestingTempDirectoryName()
58 if err != nil {
59 tb.Fatal(err)
60 }
61
62 tb.Cleanup(func() {
63 if !tb.Failed() {
64 os.RemoveAll(d) //nolint:errcheck
65 } else {
66 tb.Logf("temporary files left in %v", d)
67 }
68 })
69
70 return d
71}
72
73// TempDirectoryShort returns a short temporary directory and cleans it up before test
74// completes.

Callers 15

TestSnapshotListFunction · 0.92
TestSnapshotStorageStatsFunction · 0.92
TestSnapshotVerifyFunction · 0.92
TestSetSplitterPolicyFunction · 0.92
TestServerNotificationsFunction · 0.92
TestSetUploadPolicyFunction · 0.92
TestSnapshotPinFunction · 0.92
TestCacheSetFunction · 0.92
TestLoadPEMPathFunction · 0.92
TestLogsCommandsFunction · 0.92

Calls 5

HelperMethod · 0.80
LogfMethod · 0.80
CleanupMethod · 0.65
RemoveAllMethod · 0.45

Tested by 15

TestSnapshotListFunction · 0.74
TestSnapshotStorageStatsFunction · 0.74
TestSnapshotVerifyFunction · 0.74
TestSetSplitterPolicyFunction · 0.74
TestServerNotificationsFunction · 0.74
TestSetUploadPolicyFunction · 0.74
TestSnapshotPinFunction · 0.74
TestCacheSetFunction · 0.74
TestLoadPEMPathFunction · 0.74
TestLogsCommandsFunction · 0.74