Exemplo n.º 1
0
func (s *RemoteRepoSuite) TestDownloadFlat(c *C) {
	downloader := http.NewFakeDownloader()
	downloader.ExpectResponse("http://repos.express42.com/virool/precise/Release", exampleReleaseFile)
	downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.bz2", errors.New("HTTP 404"))
	downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.gz", errors.New("HTTP 404"))
	downloader.ExpectResponse("http://repos.express42.com/virool/precise/Packages", examplePackagesFile)
	downloader.ExpectResponse("http://repos.express42.com/virool/precise/pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb", "xyz")

	err := s.flat.Fetch(downloader, nil)
	c.Assert(err, IsNil)

	err = s.flat.Download(s.progress, downloader, s.collectionFactory, s.packagePool, false)
	c.Assert(err, IsNil)
	c.Assert(downloader.Empty(), Equals, true)
	c.Assert(s.flat.packageRefs, NotNil)

	pkg, err := s.collectionFactory.PackageCollection().ByKey(s.flat.packageRefs.Refs[0])
	c.Assert(err, IsNil)

	result, err := pkg.VerifyFiles(s.packagePool)
	c.Check(result, Equals, true)
	c.Check(err, IsNil)

	c.Check(pkg.Name, Equals, "amanda-client")
}
Exemplo n.º 2
0
func (s *RemoteRepoSuite) TestDownloadFlat(c *C) {
	downloader := http.NewFakeDownloader()
	downloader.ExpectResponse("http://repos.express42.com/virool/precise/Release", exampleReleaseFile)
	downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.bz2", &http.HTTPError{Code: 404})
	downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.gz", &http.HTTPError{Code: 404})
	downloader.ExpectResponse("http://repos.express42.com/virool/precise/Packages", examplePackagesFile)

	err := s.flat.Fetch(downloader, nil)
	c.Assert(err, IsNil)

	err = s.flat.DownloadPackageIndexes(s.progress, downloader, s.collectionFactory, false)
	c.Assert(err, IsNil)
	c.Assert(downloader.Empty(), Equals, true)

	queue, size, err := s.flat.BuildDownloadQueue(s.packagePool)
	c.Check(size, Equals, int64(3))
	c.Check(queue, HasLen, 1)
	c.Check(queue[0].RepoURI, Equals, "pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb")

	s.flat.FinalizeDownload()
	c.Assert(s.flat.packageRefs, NotNil)

	pkg, err := s.collectionFactory.PackageCollection().ByKey(s.flat.packageRefs.Refs[0])
	c.Assert(err, IsNil)

	c.Check(pkg.Name, Equals, "amanda-client")
}
Exemplo n.º 3
0
func (s *RemoteRepoSuite) TestFetchNullVerifier2(c *C) {
	downloader := http.NewFakeDownloader()
	downloader.ExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/InRelease", exampleReleaseFile)

	err := s.repo.Fetch(downloader, &NullVerifier{})
	c.Assert(err, IsNil)
	c.Assert(s.repo.Architectures, DeepEquals, []string{"amd64", "armel", "armhf", "i386", "powerpc"})
	c.Assert(s.repo.Components, DeepEquals, []string{"main"})
	c.Assert(downloader.Empty(), Equals, true)
}
Exemplo n.º 4
0
func (s *RemoteRepoSuite) SetUpTest(c *C) {
	s.repo, _ = NewRemoteRepo("yandex", "http://mirror.yandex.ru/debian", "squeeze", []string{"main"}, []string{}, false)
	s.flat, _ = NewRemoteRepo("exp42", "http://repos.express42.com/virool/precise/", "./", []string{}, []string{}, false)
	s.downloader = http.NewFakeDownloader().ExpectResponse("http://mirror.yandex.ru/debian/dists/squeeze/Release", exampleReleaseFile)
	s.progress = console.NewProgress()
	s.db, _ = database.OpenDB(c.MkDir())
	s.collectionFactory = NewCollectionFactory(s.db)
	s.packagePool = files.NewPackagePool(c.MkDir())
	s.SetUpPackages()
	s.progress.Start()
}
Exemplo n.º 5
0
func (s *RemoteRepoSuite) TestDownloadWithSourcesFlat(c *C) {
	s.flat.DownloadSources = true

	downloader := http.NewFakeDownloader()
	downloader.ExpectResponse("http://repos.express42.com/virool/precise/Release", exampleReleaseFile)
	downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.bz2", &http.HTTPError{Code: 404})
	downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.gz", &http.HTTPError{Code: 404})
	downloader.ExpectResponse("http://repos.express42.com/virool/precise/Packages", examplePackagesFile)
	downloader.ExpectError("http://repos.express42.com/virool/precise/Sources.bz2", &http.HTTPError{Code: 404})
	downloader.ExpectError("http://repos.express42.com/virool/precise/Sources.gz", &http.HTTPError{Code: 404})
	downloader.ExpectResponse("http://repos.express42.com/virool/precise/Sources", exampleSourcesFile)

	err := s.flat.Fetch(downloader, nil)
	c.Assert(err, IsNil)

	err = s.flat.DownloadPackageIndexes(s.progress, downloader, s.collectionFactory, false)
	c.Assert(err, IsNil)
	c.Assert(downloader.Empty(), Equals, true)

	queue, size, err := s.flat.BuildDownloadQueue(s.packagePool)
	c.Check(size, Equals, int64(15))
	c.Check(queue, HasLen, 4)

	q := make([]string, 4)
	for i := range q {
		q[i] = queue[i].RepoURI
	}
	sort.Strings(q)
	c.Check(q[3], Equals, "pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb")
	c.Check(q[1], Equals, "pool/main/a/access-modifier-checker/access-modifier-checker_1.0-4.dsc")
	c.Check(q[2], Equals, "pool/main/a/access-modifier-checker/access-modifier-checker_1.0.orig.tar.gz")
	c.Check(q[0], Equals, "pool/main/a/access-modifier-checker/access-modifier-checker_1.0-4.debian.tar.gz")

	s.flat.FinalizeDownload()
	c.Assert(s.flat.packageRefs, NotNil)

	pkg, err := s.collectionFactory.PackageCollection().ByKey(s.flat.packageRefs.Refs[0])
	c.Assert(err, IsNil)

	c.Check(pkg.Name, Equals, "amanda-client")

	pkg, err = s.collectionFactory.PackageCollection().ByKey(s.flat.packageRefs.Refs[1])
	c.Assert(err, IsNil)

	c.Check(pkg.Name, Equals, "access-modifier-checker")
}
Exemplo n.º 6
0
func (s *RemoteRepoSuite) TestDownloadWithSourcesFlat(c *C) {
	s.flat.DownloadSources = true

	downloader := http.NewFakeDownloader()
	downloader.ExpectResponse("http://repos.express42.com/virool/precise/Release", exampleReleaseFile)
	downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.bz2", errors.New("HTTP 404"))
	downloader.ExpectError("http://repos.express42.com/virool/precise/Packages.gz", errors.New("HTTP 404"))
	downloader.ExpectResponse("http://repos.express42.com/virool/precise/Packages", examplePackagesFile)
	downloader.ExpectError("http://repos.express42.com/virool/precise/Sources.bz2", errors.New("HTTP 404"))
	downloader.ExpectError("http://repos.express42.com/virool/precise/Sources.gz", errors.New("HTTP 404"))
	downloader.ExpectResponse("http://repos.express42.com/virool/precise/Sources", exampleSourcesFile)
	downloader.AnyExpectResponse("http://repos.express42.com/virool/precise/pool/main/a/amanda/amanda-client_3.3.1-3~bpo60+1_amd64.deb", "xyz")
	downloader.AnyExpectResponse("http://repos.express42.com/virool/precise/pool/main/a/access-modifier-checker/access-modifier-checker_1.0-4.dsc", "abc")
	downloader.AnyExpectResponse("http://repos.express42.com/virool/precise/pool/main/a/access-modifier-checker/access-modifier-checker_1.0.orig.tar.gz", "abcd")
	downloader.AnyExpectResponse("http://repos.express42.com/virool/precise/pool/main/a/access-modifier-checker/access-modifier-checker_1.0-4.debian.tar.gz", "abcde")

	err := s.flat.Fetch(downloader, nil)
	c.Assert(err, IsNil)

	err = s.flat.Download(s.progress, downloader, s.packageCollection, s.packagePool, false)
	c.Assert(err, IsNil)
	c.Assert(downloader.Empty(), Equals, true)
	c.Assert(s.flat.packageRefs, NotNil)

	pkg, err := s.packageCollection.ByKey(s.flat.packageRefs.Refs[0])
	c.Assert(err, IsNil)

	result, err := pkg.VerifyFiles(s.packagePool)
	c.Check(result, Equals, true)
	c.Check(err, IsNil)

	c.Check(pkg.Name, Equals, "amanda-client")

	pkg, err = s.packageCollection.ByKey(s.flat.packageRefs.Refs[1])
	c.Assert(err, IsNil)

	result, err = pkg.VerifyFiles(s.packagePool)
	c.Check(result, Equals, true)
	c.Check(err, IsNil)

	c.Check(pkg.Name, Equals, "access-modifier-checker")
}