mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-20 12:47:35 +00:00
Fix unit-tests. #324
This commit is contained in:
+2
-2
@@ -334,7 +334,7 @@ func (s *RemoteRepoSuite) TestDownloadFlat(c *C) {
|
|||||||
err := s.flat.Fetch(downloader, nil)
|
err := s.flat.Fetch(downloader, nil)
|
||||||
c.Assert(err, IsNil)
|
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(err, IsNil)
|
||||||
c.Assert(downloader.Empty(), Equals, true)
|
c.Assert(downloader.Empty(), Equals, true)
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ func (s *RemoteRepoSuite) TestDownloadWithSourcesFlat(c *C) {
|
|||||||
err := s.flat.Fetch(downloader, nil)
|
err := s.flat.Fetch(downloader, nil)
|
||||||
c.Assert(err, IsNil)
|
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(err, IsNil)
|
||||||
c.Assert(downloader.Empty(), Equals, true)
|
c.Assert(downloader.Empty(), Equals, true)
|
||||||
|
|
||||||
|
|||||||
@@ -349,5 +349,9 @@ func DownloadTryCompression(downloader aptly.Downloader, url string, expectedChe
|
|||||||
|
|
||||||
return uncompressed, file, err
|
return uncompressed, file, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
err = fmt.Errorf("no candidates for %s found", url)
|
||||||
|
}
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,27 +257,32 @@ func (s *DownloaderSuite) TestDownloadTryCompression(c *C) {
|
|||||||
d = NewFakeDownloader()
|
d = NewFakeDownloader()
|
||||||
d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404})
|
d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404})
|
||||||
d.ExpectResponse("http://example.com/file.gz", "x")
|
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(err, ErrorMatches, "unexpected EOF")
|
||||||
c.Assert(d.Empty(), Equals, true)
|
c.Assert(d.Empty(), Equals, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DownloaderSuite) TestDownloadTryCompressionErrors(c *C) {
|
func (s *DownloaderSuite) TestDownloadTryCompressionErrors(c *C) {
|
||||||
d := NewFakeDownloader()
|
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.*")
|
c.Assert(err, ErrorMatches, "unexpected request.*")
|
||||||
|
|
||||||
d = NewFakeDownloader()
|
d = NewFakeDownloader()
|
||||||
d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404})
|
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.gz", &HTTPError{Code: 404})
|
||||||
d.ExpectError("http://example.com/file", errors.New("403"))
|
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")
|
c.Assert(err, ErrorMatches, "403")
|
||||||
|
|
||||||
d = NewFakeDownloader()
|
d = NewFakeDownloader()
|
||||||
d.ExpectError("http://example.com/file.bz2", &HTTPError{Code: 404})
|
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.gz", &HTTPError{Code: 404})
|
||||||
d.ExpectResponse("http://example.com/file", rawData)
|
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.*")
|
c.Assert(err, ErrorMatches, "checksums don't match.*")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user