Skip to content

Commit

Permalink
test(taskfile): move t.TempDir call inside helper
Browse files Browse the repository at this point in the history
  • Loading branch information
jlucktay committed Jul 4, 2024
1 parent 0eadafa commit ea22989
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions taskfile/cache_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ var discardLogger = &logger.Logger{
Stderr: io.Discard,
}

func primeNewCache(t *testing.T, tempDir string, cacheOpts ...CacheOption) (*Cache, *FileNode) {
func primeNewCache(t *testing.T, cacheOpts ...CacheOption) (*Cache, *FileNode) {
t.Helper()

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

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

func TestCache(t *testing.T) {
cache, fileNode := primeNewCache(t, t.TempDir())
cache, fileNode := primeNewCache(t)

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

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

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

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

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

0 comments on commit ea22989

Please sign in to comment.