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


Golang Package.Stemcell方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry/bosh-init/release/pkg.Package.Stemcell方法的典型用法代码示例。如果您正苦于以下问题:Golang Package.Stemcell方法的具体用法?Golang Package.Stemcell怎么用?Golang Package.Stemcell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry/bosh-init/release/pkg.Package的用法示例。


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

示例1: describeRemotePackageCompiler


//.........这里部分代码省略.........
			BlobID:   "fake-compiled-package-blob-id-dep",
			BlobSHA1: "fake-compiled-package-sha1-dep",
		}

		compiledPackages = map[bistatepkg.CompiledPackageRecord]*birelpkg.Package{
			depRecord1: pkgDependency,
		}
	})

	JustBeforeEach(func() {
		// add compiled packages to the repo
		for record, dependency := range compiledPackages {
			err := packageRepo.Save(*dependency, record)
			Expect(err).ToNot(HaveOccurred())
		}

		packageSource := biagentclient.BlobRef{
			Name:        "fake-package-name",
			Version:     "fake-package-fingerprint",
			BlobstoreID: "fake-source-package-blob-id",
			SHA1:        "fake-source-package-sha1",
		}
		packageDependencies := []biagentclient.BlobRef{
			{
				Name:        "fake-package-name-dep",
				Version:     "fake-package-fingerprint-dep",
				BlobstoreID: "fake-compiled-package-blob-id-dep",
				SHA1:        "fake-compiled-package-sha1-dep",
			},
		}
		compiledPackageRef := biagentclient.BlobRef{
			Name:        "fake-package-name",
			Version:     "fake-package-version",
			BlobstoreID: "fake-compiled-package-blob-id",
			SHA1:        "fake-compiled-package-sha1",
		}

		expectBlobstoreAdd = mockBlobstore.EXPECT().Add(archivePath).Return("fake-source-package-blob-id", nil).AnyTimes()
		expectAgentCompile = mockAgentClient.EXPECT().CompilePackage(packageSource, packageDependencies).Return(compiledPackageRef, nil).AnyTimes()
	})

	Describe("Compile", func() {
		It("uploads the package archive to the blobstore and then compiles the package with the agent", func() {
			gomock.InOrder(
				expectBlobstoreAdd.Times(1),
				expectAgentCompile.Times(1),
			)

			compiledPackageRecord, _, err := remotePackageCompiler.Compile(pkg)
			Expect(err).ToNot(HaveOccurred())
			Expect(compiledPackageRecord).To(Equal(bistatepkg.CompiledPackageRecord{
				BlobID:   "fake-compiled-package-blob-id",
				BlobSHA1: "fake-compiled-package-sha1",
			}))
		})

		It("saves the compiled package ref in the package repo", func() {
			compiledPackageRecord, _, err := remotePackageCompiler.Compile(pkg)
			Expect(err).ToNot(HaveOccurred())

			record, found, err := packageRepo.Find(*pkg)
			Expect(err).ToNot(HaveOccurred())
			Expect(found).To(BeTrue())
			Expect(record).To(Equal(compiledPackageRecord))
		})

		Context("when the dependencies are not in the repo", func() {
			BeforeEach(func() {
				compiledPackages = map[bistatepkg.CompiledPackageRecord]*birelpkg.Package{}
			})

			It("returns an error", func() {
				_, _, err := remotePackageCompiler.Compile(pkg)
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("Remote compilation failure: Package 'fake-package-name/fake-package-fingerprint' requires package 'fake-package-name-dep/fake-package-fingerprint-dep', but it has not been compiled"))
			})
		})

		Context("when package belongs to a compiled release", func() {
			BeforeEach(func() {
				pkg.Stemcell = "ubuntu/fake"
			})

			AfterEach(func() {
				pkg.Stemcell = ""
			})

			It("should skip compilation", func() {
				compiledPackageRecord, isAlreadyCompiled, err := remotePackageCompiler.Compile(pkg)

				expectAgentCompile.Times(0)

				Expect(err).ToNot(HaveOccurred())
				Expect(isAlreadyCompiled).To(Equal(true))
				Expect(compiledPackageRecord.BlobID).To(Equal("fake-source-package-blob-id"))
				Expect(compiledPackageRecord.BlobSHA1).To(Equal(pkg.SHA1))
			})
		})
	})
}
开发者ID:hanzhefeng,项目名称:bosh-init,代码行数:101,代码来源:remote_package_compiler_test.go


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