diff --git a/deb/remote_test.go b/deb/remote_test.go index ba55a1dd..7d0f64dc 100644 --- a/deb/remote_test.go +++ b/deb/remote_test.go @@ -334,7 +334,7 @@ func (s *RemoteRepoSuite) TestDownloadFlat(c *C) { err := s.flat.Fetch(downloader, nil) c.Assert(err, IsNil) - err = s.flat.DownloadPackageIndexes(s.progress, downloader, s.collectionFactory, false) + err = s.flat.DownloadPackageIndexes(s.progress, downloader, s.collectionFactory, true) c.Assert(err, IsNil) c.Assert(downloader.Empty(), Equals, true) @@ -367,7 +367,7 @@ func (s *RemoteRepoSuite) TestDownloadWithSourcesFlat(c *C) { err := s.flat.Fetch(downloader, nil) c.Assert(err, IsNil) - err = s.flat.DownloadPackageIndexes(s.progress, downloader, s.collectionFactory, false) + err = s.flat.DownloadPackageIndexes(s.progress, downloader, s.collectionFactory, true) c.Assert(err, IsNil) c.Assert(downloader.Empty(), Equals, true) diff --git a/http/download.go b/http/download.go index 3d8e4f32..c2aef32a 100644 --- a/http/download.go +++ b/http/download.go @@ -349,5 +349,9 @@ func DownloadTryCompression(downloader aptly.Downloader, url string, expectedChe return uncompressed, file, err } + + if err == nil { + err = fmt.Errorf("no candidates for %s found", url) + } return nil, nil, err } diff --git a/http/download_test.go b/http/download_test.go index d5eda5b4..b63fd665 100644 --- a/http/download_test.go +++ b/http/download_test.go @@ -257,27 +257,32 @@ func (s *DownloaderSuite) TestDownloadTryCompression(c *C) { d = NewFakeDownloader() d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404}) d.ExpectResponse("http://example.com/file.gz", "x") - r, file, err = DownloadTryCompression(d, "http://example.com/file", nil, false) + r, file, err = DownloadTryCompression(d, "http://example.com/file", nil, true) c.Assert(err, ErrorMatches, "unexpected EOF") c.Assert(d.Empty(), Equals, true) } func (s *DownloaderSuite) TestDownloadTryCompressionErrors(c *C) { d := NewFakeDownloader() - _, _, err := DownloadTryCompression(d, "http://example.com/file", nil, false) + _, _, err := DownloadTryCompression(d, "http://example.com/file", nil, true) c.Assert(err, ErrorMatches, "unexpected request.*") d = NewFakeDownloader() d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404}) d.ExpectError("http://example.com/file.gz", &HTTPError{Code: 404}) d.ExpectError("http://example.com/file", errors.New("403")) - _, _, err = DownloadTryCompression(d, "http://example.com/file", nil, false) + _, _, err = DownloadTryCompression(d, "http://example.com/file", nil, true) c.Assert(err, ErrorMatches, "403") d = NewFakeDownloader() d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404}) d.ExpectError("http://example.com/file.gz", &HTTPError{Code: 404}) d.ExpectResponse("http://example.com/file", rawData) - _, _, err = DownloadTryCompression(d, "http://example.com/file", map[string]utils.ChecksumInfo{"file": {Size: 7}}, false) + expectedChecksums := map[string]utils.ChecksumInfo{ + "file.bz2": {Size: 7}, + "file.gz": {Size: 7}, + "file": {Size: 7}, + } + _, _, err = DownloadTryCompression(d, "http://example.com/file", expectedChecksums, false) c.Assert(err, ErrorMatches, "checksums don't match.*") }