Skip to content

Commit 6230c71

Browse files
committed
test(taskfile): move t.TempDir call inside helper
1 parent d733fc0 commit 6230c71

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

taskfile/cache_internal_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ var discardLogger = &logger.Logger{
2525
Stderr: io.Discard,
2626
}
2727

28-
func primeNewCache(t *testing.T, tempDir string, cacheOpts ...CacheOption) (*Cache, *FileNode) {
28+
func primeNewCache(t *testing.T, cacheOpts ...CacheOption) (*Cache, *FileNode) {
2929
t.Helper()
3030

31-
cache, err := NewCache(tempDir, cacheOpts...)
32-
require.NoErrorf(t, err, "creating new cache in temporary directory '%s'", tempDir)
31+
cache, err := NewCache(t.TempDir(), cacheOpts...)
32+
require.NoErrorf(t, err, "creating new cache")
3333

3434
// Prime the temporary cache directory with a basic Taskfile.
3535
filename := "Taskfile.yaml"
@@ -50,7 +50,7 @@ func primeNewCache(t *testing.T, tempDir string, cacheOpts ...CacheOption) (*Cac
5050
}
5151

5252
func TestCache(t *testing.T) {
53-
cache, fileNode := primeNewCache(t, t.TempDir())
53+
cache, fileNode := primeNewCache(t)
5454

5555
// Attempt to read from cache, then write, then read again.
5656
_, err := cache.read(fileNode)
@@ -67,7 +67,7 @@ func TestCache(t *testing.T) {
6767

6868
func TestCacheInsideTTL(t *testing.T) {
6969
// Prime a new Cache with a TTL of one minute.
70-
cache, fileNode := primeNewCache(t, t.TempDir(), WithTTL(time.Minute))
70+
cache, fileNode := primeNewCache(t, WithTTL(time.Minute))
7171

7272
// Write some bytes for the cached file.
7373
writeBytes := []byte("some bytes")
@@ -82,7 +82,7 @@ func TestCacheInsideTTL(t *testing.T) {
8282

8383
func TestCacheOutsideTTL(t *testing.T) {
8484
// Prime a new Cache with an extremely short TTL.
85-
cache, fileNode := primeNewCache(t, t.TempDir(), WithTTL(time.Millisecond))
85+
cache, fileNode := primeNewCache(t, WithTTL(time.Millisecond))
8686

8787
// Write some bytes for the cached file.
8888
writeBytes := []byte("some bytes")

0 commit comments

Comments
 (0)