@@ -19,7 +19,7 @@ import (
19
19
20
20
func TestMain (m * testing.M ) {
21
21
HideProgress = true
22
- os . Exit ( m .Run () )
22
+ m .Run ()
23
23
}
24
24
25
25
type downloadResult struct {
@@ -189,21 +189,13 @@ func TestDownloadRemote(t *testing.T) {
189
189
}
190
190
191
191
func TestRedownloadRemote (t * testing.T ) {
192
- remoteDir , err := os .MkdirTemp ("" , "redownloadRemote" )
193
- assert .NilError (t , err )
194
- t .Cleanup (func () { _ = os .RemoveAll (remoteDir ) })
192
+ remoteDir := t .TempDir ()
195
193
ts := httptest .NewServer (http .FileServer (http .Dir (remoteDir )))
196
194
t .Cleanup (ts .Close )
197
195
198
- cacheDir , err := os .MkdirTemp ("" , "redownloadCache" )
199
- assert .NilError (t , err )
200
- t .Cleanup (func () { _ = os .RemoveAll (cacheDir ) })
196
+ downloadDir := t .TempDir ()
201
197
202
- downloadDir , err := os .MkdirTemp ("" , "redownloadLocal" )
203
- assert .NilError (t , err )
204
- t .Cleanup (func () { _ = os .RemoveAll (downloadDir ) })
205
-
206
- cacheOpt := WithCacheDir (cacheDir )
198
+ cacheOpt := WithCacheDir (t .TempDir ())
207
199
208
200
t .Run ("digest-less" , func (t * testing.T ) {
209
201
remoteFile := filepath .Join (remoteDir , "digest-less.txt" )
@@ -283,8 +275,6 @@ func TestDownloadLocal(t *testing.T) {
283
275
r , err := Download (context .Background (), localPath , testLocalFileURL , WithExpectedDigest (testDownloadLocalDigest ))
284
276
assert .NilError (t , err )
285
277
assert .Equal (t , StatusDownloaded , r .Status )
286
-
287
- os .Remove (localTestFile )
288
278
})
289
279
290
280
t .Run ("cached" , func (t * testing.T ) {
0 commit comments