Skip to content

Commit 946dae9

Browse files
author
aibuddy
committed
[tests][S01-MakeRepoRelTempDir] Refactor fs_mkdirp test to use shared MakeRepoRelTempDir helper; keep tests DRY and deterministic. Links: #1
1 parent 56ccd25 commit 946dae9

1 file changed

Lines changed: 1 addition & 14 deletions

File tree

tools/cmd/fs_mkdirp/fs_mkdirp_test.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,10 @@ func runFsMkdirp(t *testing.T, bin string, input any) (fsMkdirpOutput, string, i
4545
return out, stderr.String(), code
4646
}
4747

48-
// makeRepoRelTempDir creates a temporary directory under the repository root
49-
// (current working directory in tests) and returns the relative path.
50-
func makeRepoRelTempDir(t *testing.T, prefix string) string {
51-
t.Helper()
52-
tmpAbs, err := os.MkdirTemp(".", prefix)
53-
if err != nil {
54-
t.Fatalf("mkdir temp under repo: %v", err)
55-
}
56-
base := filepath.Base(tmpAbs)
57-
t.Cleanup(func() { _ = os.RemoveAll(base) })
58-
return base
59-
}
60-
6148
func TestFsMkdirp_DeepCreateAndIdempotence(t *testing.T) {
6249
bin := testutil.BuildTool(t, "fs_mkdirp")
6350

64-
dir := makeRepoRelTempDir(t, "fsmkdirp-")
51+
dir := testutil.MakeRepoRelTempDir(t, "fsmkdirp-")
6552
deep := filepath.Join(dir, "a", "b", "c")
6653

6754
// First call should create directories

0 commit comments

Comments
 (0)