MCPcopy Create free account
hub / github.com/aptly-dev/aptly / TestDownloadAppStreamFiles

Method TestDownloadAppStreamFiles

deb/remote_test.go:728–794  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

726}
727
728func (s *RemoteRepoSuite) TestDownloadAppStreamFiles(c *C) {
729 // No dep11 entries
730 s.repo.Components = []string{"main"}
731 s.repo.ReleaseFiles = map[string]utils.ChecksumInfo{
732 "main/binary-amd64/Packages": {Size: 100},
733 "main/source/Sources": {Size: 200},
734 }
735
736 err := s.repo.DownloadAppStreamFiles(s.progress, s.downloader, s.packagePool, s.cs, false)
737 c.Assert(err, IsNil)
738 c.Check(s.repo.AppStreamFiles, HasLen, 0)
739
740 s.repo.ReleaseFiles = map[string]utils.ChecksumInfo{
741 "main/dep11/Components-amd64.yml.gz": {Size: 16},
742 "main/dep11/icons-48x48.tar.gz": {Size: 16},
743 "main/binary-amd64/Packages": {Size: 100},
744 }
745
746 downloader := http.NewFakeDownloader()
747 downloader.AnyExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/main/dep11/Components-amd64.yml.gz", "dep11-components")
748 downloader.AnyExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/main/dep11/icons-48x48.tar.gz", "dep11-icons-data")
749
750 err = s.repo.DownloadAppStreamFiles(s.progress, downloader, s.packagePool, s.cs, false)
751 c.Assert(err, IsNil)
752 c.Check(s.repo.AppStreamFiles, HasLen, 2)
753 c.Check(s.repo.AppStreamFiles["main/dep11/Components-amd64.yml.gz"], Not(Equals), "")
754 c.Check(s.repo.AppStreamFiles["main/dep11/icons-48x48.tar.gz"], Not(Equals), "")
755
756 // 404 skipped
757 s.repo.ReleaseFiles = map[string]utils.ChecksumInfo{
758 "main/dep11/Components-amd64.yml.gz": {Size: 16},
759 "main/dep11/icons-48x48.tar.gz": {Size: 15},
760 }
761
762 downloader = http.NewFakeDownloader()
763 downloader.AnyExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/main/dep11/Components-amd64.yml.gz", "dep11-components")
764 downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/dep11/icons-48x48.tar.gz", &http.Error{Code: 404, URL: "http://mirror.yandex.ru/debian/dists/squeeze/main/dep11/icons-48x48.tar.gz"})
765
766 err = s.repo.DownloadAppStreamFiles(s.progress, downloader, s.packagePool, s.cs, false)
767 c.Assert(err, IsNil)
768 c.Check(s.repo.AppStreamFiles, HasLen, 1)
769 c.Check(s.repo.AppStreamFiles["main/dep11/Components-amd64.yml.gz"], Not(Equals), "")
770
771 // Generic download error propagated
772 s.repo.ReleaseFiles = map[string]utils.ChecksumInfo{
773 "main/dep11/Components-amd64.yml.gz": {Size: 18},
774 }
775
776 downloader = http.NewFakeDownloader()
777 downloader.ExpectError("http://mirror.yandex.ru/debian/dists/squeeze/main/dep11/Components-amd64.yml.gz", fmt.Errorf("connection refused"))
778
779 err = s.repo.DownloadAppStreamFiles(s.progress, downloader, s.packagePool, s.cs, false)
780 c.Assert(err, ErrorMatches, "unable to download AppStream file.*connection refused")
781
782 // Bypass checksum validation
783 s.repo.ReleaseFiles = map[string]utils.ChecksumInfo{
784 "main/dep11/Components-amd64.yml.gz": {Size: 999, MD5: "bad", SHA256: "bad"},
785 }

Callers

nothing calls this directly

Calls 5

AnyExpectResponseMethod · 0.95
ExpectErrorMethod · 0.95
NewFakeDownloaderFunction · 0.92
CheckMethod · 0.45

Tested by

no test coverage detected