diff options
Diffstat (limited to 'cache/filecache/filecache_test.go')
-rw-r--r-- | cache/filecache/filecache_test.go | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/cache/filecache/filecache_test.go b/cache/filecache/filecache_test.go index 47b5a7fcf..6b96a8601 100644 --- a/cache/filecache/filecache_test.go +++ b/cache/filecache/filecache_test.go @@ -17,8 +17,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" - "os" "path/filepath" "strings" "sync" @@ -44,13 +42,8 @@ func TestFileCache(t *testing.T) { t.Parallel() c := qt.New(t) - tempWorkingDir, err := ioutil.TempDir("", "hugo_filecache_test_work") - c.Assert(err, qt.IsNil) - defer os.Remove(tempWorkingDir) - - tempCacheDir, err := ioutil.TempDir("", "hugo_filecache_test_cache") - c.Assert(err, qt.IsNil) - defer os.Remove(tempCacheDir) + tempWorkingDir := t.TempDir() + tempCacheDir := t.TempDir() osfs := afero.NewOsFs() @@ -123,7 +116,7 @@ dir = ":cacheDir/c" io.Closer }{ strings.NewReader(s), - ioutil.NopCloser(nil), + io.NopCloser(nil), }, nil } } @@ -138,7 +131,7 @@ dir = ":cacheDir/c" c.Assert(err, qt.IsNil) c.Assert(r, qt.Not(qt.IsNil)) c.Assert(info.Name, qt.Equals, "a") - b, _ := ioutil.ReadAll(r) + b, _ := io.ReadAll(r) r.Close() c.Assert(string(b), qt.Equals, "abc") @@ -154,7 +147,7 @@ dir = ":cacheDir/c" _, r, err = ca.GetOrCreate("a", rf("bcd")) c.Assert(err, qt.IsNil) - b, _ = ioutil.ReadAll(r) + b, _ = io.ReadAll(r) r.Close() c.Assert(string(b), qt.Equals, "abc") } @@ -173,7 +166,7 @@ dir = ":cacheDir/c" c.Assert(err, qt.IsNil) c.Assert(r, qt.Not(qt.IsNil)) c.Assert(info.Name, qt.Equals, "mykey") - b, _ := ioutil.ReadAll(r) + b, _ := io.ReadAll(r) r.Close() c.Assert(string(b), qt.Equals, "Hugo is great!") @@ -233,7 +226,7 @@ dir = "/cache/c" return hugio.ToReadCloser(strings.NewReader(data)), nil }) c.Assert(err, qt.IsNil) - b, _ := ioutil.ReadAll(r) + b, _ := io.ReadAll(r) r.Close() c.Assert(string(b), qt.Equals, data) // Trigger some expiration. @@ -260,7 +253,7 @@ func TestFileCacheReadOrCreateErrorInRead(t *testing.T) { return errors.New("fail") } - b, _ := ioutil.ReadAll(r) + b, _ := io.ReadAll(r) result = string(b) return nil |