diff --git a/pkg/downloader/downloader_test.go b/pkg/downloader/downloader_test.go index 2e4483194cb..508f09a7e40 100644 --- a/pkg/downloader/downloader_test.go +++ b/pkg/downloader/downloader_test.go @@ -203,18 +203,26 @@ func TestRedownloadRemote(t *testing.T) { assert.NilError(t, os.Chtimes(remoteFile, time.Now(), time.Now().Add(-time.Hour))) opt := []Opt{cacheOpt} + // Download on the first call r, err := Download(context.Background(), filepath.Join(downloadDir, "digest-less1.txt"), ts.URL+"/digest-less.txt", opt...) assert.NilError(t, err) assert.Equal(t, StatusDownloaded, r.Status) + + // Next download will use the cached download r, err = Download(context.Background(), filepath.Join(downloadDir, "digest-less2.txt"), ts.URL+"/digest-less.txt", opt...) assert.NilError(t, err) assert.Equal(t, StatusUsedCache, r.Status) - // modifying remote file will cause redownload + // Modifying remote file will cause redownload assert.NilError(t, os.Chtimes(remoteFile, time.Now(), time.Now())) r, err = Download(context.Background(), filepath.Join(downloadDir, "digest-less3.txt"), ts.URL+"/digest-less.txt", opt...) assert.NilError(t, err) assert.Equal(t, StatusDownloaded, r.Status) + + // Next download will use the cached download + r, err = Download(context.Background(), filepath.Join(downloadDir, "digest-less4.txt"), ts.URL+"/digest-less.txt", opt...) + assert.NilError(t, err) + assert.Equal(t, StatusUsedCache, r.Status) }) t.Run("has-digest", func(t *testing.T) {