当前位置: 首页>>代码示例>>Golang>>正文


Golang http.NewFakeDownloader函数代码示例

本文整理汇总了Golang中github.com/smira/aptly/http.NewFakeDownloader函数的典型用法代码示例。如果您正苦于以下问题:Golang NewFakeDownloader函数的具体用法?Golang NewFakeDownloader怎么用?Golang NewFakeDownloader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewFakeDownloader函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestDownloadFlat

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")
}
开发者ID:ryanuber,项目名称:aptly,代码行数:25,代码来源:remote_test.go

示例2: TestDownloadFlat

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")
}
开发者ID:taku-k,项目名称:aptly,代码行数:27,代码来源:remote_test.go

示例3: TestFetchNullVerifier2

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)
}
开发者ID:ryanuber,项目名称:aptly,代码行数:10,代码来源:remote_test.go

示例4: SetUpTest

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()
}
开发者ID:ryanuber,项目名称:aptly,代码行数:11,代码来源:remote_test.go

示例5: TestDownloadWithSourcesFlat

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")
}
开发者ID:taku-k,项目名称:aptly,代码行数:46,代码来源:remote_test.go

示例6: TestDownloadWithSourcesFlat

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")
}
开发者ID:hdonnay,项目名称:aptly,代码行数:42,代码来源:remote_test.go


注:本文中的github.com/smira/aptly/http.NewFakeDownloader函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。