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


Golang Call.Times方法代码示例

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


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

示例1:

						Expect(err.Error()).To(Equal("Setting temp root: fake ChangeTempRootErr"))
					})
				})

				It("sets the temp root", func() {
					expectDeleteAndCleanup(true)
					err := newDeploymentDeleter().DeleteDeployment(fakeStage)
					Expect(err).NotTo(HaveOccurred())
					Expect(fs.TempRootPath).To(Equal("fake-install-dir/fake-installation-id/tmp"))
				})

				It("extracts & install CPI release tarball", func() {
					expectDeleteAndCleanup(true)

					gomock.InOrder(
						expectCPIExtractRelease.Times(1),
						expectCPIInstall.Times(1),
						expectNewCloud.Times(1),
					)

					err := newDeploymentDeleter().DeleteDeployment(fakeStage)
					Expect(err).NotTo(HaveOccurred())
				})

				It("deletes the extracted CPI release", func() {
					expectDeleteAndCleanup(true)

					err := newDeploymentDeleter().DeleteDeployment(fakeStage)
					Expect(err).NotTo(HaveOccurred())
					Expect(fs.FileExists("fake-cpi-extracted-dir")).To(BeFalse())
				})
开发者ID:hanzhefeng,项目名称:bosh-init,代码行数:31,代码来源:deployment_deleteter_test.go

示例2: describeRemotePackageCompiler

func describeRemotePackageCompiler() {
	var mockCtrl *gomock.Controller

	BeforeEach(func() {
		mockCtrl = gomock.NewController(GinkgoT())
	})

	AfterEach(func() {
		mockCtrl.Finish()
	})

	var (
		packageRepo bistatepkg.CompiledPackageRepo

		pkgDependency *birelpkg.Package
		pkg           *birelpkg.Package

		mockBlobstore   *mock_blobstore.MockBlobstore
		mockAgentClient *mock_agentclient.MockAgentClient

		archivePath = "fake-archive-path"

		remotePackageCompiler bistatepkg.Compiler

		compiledPackages map[bistatepkg.CompiledPackageRecord]*birelpkg.Package

		expectBlobstoreAdd *gomock.Call
		expectAgentCompile *gomock.Call
	)

	BeforeEach(func() {
		mockBlobstore = mock_blobstore.NewMockBlobstore(mockCtrl)
		mockAgentClient = mock_agentclient.NewMockAgentClient(mockCtrl)

		index := biindex.NewInMemoryIndex()
		packageRepo = bistatepkg.NewCompiledPackageRepo(index)
		remotePackageCompiler = NewRemotePackageCompiler(mockBlobstore, mockAgentClient, packageRepo)

		pkgDependency = &birelpkg.Package{
			Name:        "fake-package-name-dep",
			Fingerprint: "fake-package-fingerprint-dep",
		}

		pkg = &birelpkg.Package{
			Name:         "fake-package-name",
			Fingerprint:  "fake-package-fingerprint",
			SHA1:         "fake-source-package-sha1",
			ArchivePath:  archivePath,
			Dependencies: []*birelpkg.Package{pkgDependency},
		}

		depRecord1 := bistatepkg.CompiledPackageRecord{
			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),
			)

//.........这里部分代码省略.........
开发者ID:hanzhefeng,项目名称:bosh-init,代码行数:101,代码来源:remote_package_compiler_test.go

示例3: describeBuilder


//.........这里部分代码省略.........
				ArchivePath:  "fake-package-archive-path-cpi", // only required by compiler...
			}
		})

		JustBeforeEach(func() {
			releaseJob := bireljob.Job{
				Name:        "fake-release-job-name",
				Fingerprint: "fake-release-job-source-fingerprint",
				Packages:    []*birelpkg.Package{releasePackageCPI, releasePackageRuby},
			}
			mockReleaseJobResolver.EXPECT().Resolve("fake-release-job-name", "fake-release-name").Return(releaseJob, nil)

			releaseJobs := []bireljob.Job{releaseJob}
			compiledPackageRefs := []bistatejob.CompiledPackageRef{
				{
					Name:        "libyaml",
					Version:     "fake-package-source-fingerprint-libyaml",
					BlobstoreID: "fake-package-compiled-archive-blob-id-libyaml",
					SHA1:        "fake-package-compiled-archive-sha1-libyaml",
				},
				{
					Name:        "ruby",
					Version:     "fake-package-source-fingerprint-ruby",
					BlobstoreID: "fake-package-compiled-archive-blob-id-ruby",
					SHA1:        "fake-package-compiled-archive-sha1-ruby",
				},
				{
					Name:        "cpi",
					Version:     "fake-package-source-fingerprint-cpi",
					BlobstoreID: "fake-package-compiled-archive-blob-id-cpi",
					SHA1:        "fake-package-compiled-archive-sha1-cpi",
				},
			}
			expectCompile = mockDependencyCompiler.EXPECT().Compile(releaseJobs, fakeStage).Return(compiledPackageRefs, nil).AnyTimes()

			jobProperties := biproperty.Map{
				"fake-job-property": "fake-job-property-value",
			}
			globalProperties := biproperty.Map{
				"fake-job-property": "fake-global-property-value",
			}
			mockJobListRenderer.EXPECT().Render(releaseJobs, jobProperties, globalProperties, "fake-deployment-name").Return(mockRenderedJobList, nil)

			mockRenderedJobList.EXPECT().DeleteSilently()

			mockCompressor.EXPECT().Compress(mockRenderedJobList).Return(mockRenderedJobListArchive, nil)

			mockRenderedJobListArchive.EXPECT().DeleteSilently()

			mockRenderedJobListArchive.EXPECT().Path().Return("fake-rendered-job-list-archive-path")
			mockRenderedJobListArchive.EXPECT().SHA1().Return("fake-rendered-job-list-archive-sha1")
			mockRenderedJobListArchive.EXPECT().Fingerprint().Return("fake-rendered-job-list-fingerprint")

			mockBlobstore.EXPECT().Add("fake-rendered-job-list-archive-path").Return("fake-rendered-job-list-archive-blob-id", nil)
		})

		It("compiles the dependencies of the jobs", func() {
			expectCompile.Times(1)

			_, err := stateBuilder.Build(jobName, instanceID, deploymentManifest, fakeStage)
			Expect(err).ToNot(HaveOccurred())
		})

		It("builds a new instance state with zero-to-many networks", func() {
			state, err := stateBuilder.Build(jobName, instanceID, deploymentManifest, fakeStage)
			Expect(err).ToNot(HaveOccurred())
开发者ID:vestel,项目名称:bosh-init,代码行数:67,代码来源:builder_test.go

示例4:

		Context("when no current instances, disks, or stemcells exist", func() {
			It("returns not found", func() {
				_, found, err := deploymentManager.FindCurrent()
				Expect(err).ToNot(HaveOccurred())
				Expect(found).To(BeFalse())
			})
		})

		Context("when current instances exist", func() {
			BeforeEach(func() {
				instance := mock_instance.NewMockInstance(mockCtrl)
				expectedInstances = append(expectedInstances, instance)
			})

			It("returns a deployment that wraps the current instances, disks, & stemcells", func() {
				expectNewDeployment.Times(1)

				deployment, found, err := deploymentManager.FindCurrent()
				Expect(err).ToNot(HaveOccurred())
				Expect(found).To(BeTrue())
				Expect(deployment).To(Equal(mockDeployment))
			})
		})

		Context("when current disk exist", func() {
			BeforeEach(func() {
				disk := mock_disk.NewMockDisk(mockCtrl)
				expectedDisks = append(expectedDisks, disk)
			})

			It("returns a deployment that wraps the current instances, disks, & stemcells", func() {
开发者ID:vestel,项目名称:bosh-init,代码行数:31,代码来源:manager_test.go

示例5:

				},
			}

			// apply spec is just returned from instance.State.ToApplySpec() and passed to agentClient.Apply()
			applySpec = bias.ApplySpec{
				Deployment: "fake-deployment-name",
			}
		})

		JustBeforeEach(func() {
			expectStateBuild = mockStateBuilder.EXPECT().Build(jobName, jobIndex, deploymentManifest, fakeStage).Return(mockState, nil).AnyTimes()
			mockState.EXPECT().ToApplySpec().Return(applySpec).AnyTimes()
		})

		It("builds a new instance state", func() {
			expectStateBuild.Times(1)

			err := instance.UpdateJobs(deploymentManifest, fakeStage)
			Expect(err).ToNot(HaveOccurred())
		})

		It("tells agent to stop jobs, apply a new spec (with new rendered jobs templates), and start jobs", func() {
			err := instance.UpdateJobs(deploymentManifest, fakeStage)
			Expect(err).NotTo(HaveOccurred())

			Expect(fakeVM.StopCalled).To(Equal(1))
			Expect(fakeVM.ApplyInputs).To(Equal([]fakebivm.ApplyInput{
				{ApplySpec: applySpec},
			}))
			Expect(fakeVM.StartCalled).To(Equal(1))
		})
开发者ID:vestel,项目名称:bosh-init,代码行数:31,代码来源:instance_test.go

示例6:

		Context("the function fails", func() {
			It("stops the registry and returns the error", func() {
				stopCall.After(spyCall)
				err := newInstalation().WithRunningRegistry(logger, fakeStage, func() error {
					spy.Record()
					return errors.New("blarg!")
				})
				Expect(err).To(HaveOccurred())
			})
		})

		Context("when starting registry fails", func() {
			It("returns an error and doesn't call the function", func() {
				startCall.Return(mockRegistryServer, errors.New("registry-start-error"))
				spyCall.Times(0)
				stopCall.Times(0)

				err := newInstalation().WithRunningRegistry(logger, fakeStage, func() error {
					spy.Record()
					return nil
				})

				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(Equal("Starting registry: registry-start-error"))
			})
		})

		Context("when stopping registry fails", func() {
			Context("when the function fails", func() {
				It("logs a warning and returns the function error", func() {
开发者ID:vestel,项目名称:bosh-init,代码行数:30,代码来源:installation_test.go

示例7:

			_, err := compiler.Compile(pkg)
			Expect(err).ToNot(HaveOccurred())

			Expect(compressor.CompressFilesInDirDir).To(Equal(installPath))
			Expect(compressor.CleanUpTarballPath).To(Equal(compiledPackageTarballPath))
		})

		It("moves the compressed package to a blobstore", func() {
			_, err := compiler.Compile(pkg)
			Expect(err).ToNot(HaveOccurred())

			Expect(blobstore.CreateFileNames).To(Equal([]string{compiledPackageTarballPath}))
		})

		It("stores the compiled package blobID and fingerprint into the compile package repo", func() {
			expectSave.Times(1)

			_, err := compiler.Compile(pkg)
			Expect(err).ToNot(HaveOccurred())
		})

		It("returns the repo record", func() {
			record, err := compiler.Compile(pkg)
			Expect(err).ToNot(HaveOccurred())

			Expect(record).To(Equal(bistatepkg.CompiledPackageRecord{
				BlobID:   "fake-blob-id",
				BlobSHA1: "fake-fingerprint",
			}))
		})
开发者ID:vestel,项目名称:bosh-init,代码行数:30,代码来源:compiler_test.go

示例8: rootDesc


//.........这里部分代码省略.........
			expectStemcellDeleteUnused *gomock.Call
			expectCPIReleaseExtract    *gomock.Call
			expectInstall              *gomock.Call
			expectNewCloud             *gomock.Call
		)

		BeforeEach(func() {
			logger = boshlog.NewLogger(boshlog.LevelNone)
			stdOut = gbytes.NewBuffer()
			stdErr = gbytes.NewBuffer()
			userInterface = biui.NewWriterUI(stdOut, stdErr, logger)
			fakeFs = fakesys.NewFakeFileSystem()
			fakeFs.EnableStrictTempRootBehavior()
			deploymentManifestPath = "/path/to/manifest.yml"
			deploymentStatePath = "/path/to/manifest-state.json"
			fakeFs.RegisterOpenFile(deploymentManifestPath, &fakesys.FakeFile{
				Stats: &fakesys.FakeFileStats{FileType: fakesys.FakeFileTypeFile},
			})

			fakeFs.WriteFileString(deploymentManifestPath, "")

			mockDeployer = mock_deployment.NewMockDeployer(mockCtrl)
			mockInstaller = mock_install.NewMockInstaller(mockCtrl)
			mockInstallerFactory = mock_install.NewMockInstallerFactory(mockCtrl)

			mockReleaseExtractor = mock_release.NewMockExtractor(mockCtrl)
			releaseManager = birel.NewManager(logger)

			mockRegistryServerManager = mock_registry.NewMockServerManager(mockCtrl)
			mockRegistryServer = mock_registry.NewMockServer(mockCtrl)

			mockAgentClientFactory = mock_httpagent.NewMockAgentClientFactory(mockCtrl)
			mockAgentClient = mock_agentclient.NewMockAgentClient(mockCtrl)
			mockAgentClientFactory.EXPECT().NewAgentClient(gomock.Any(), gomock.Any()).Return(mockAgentClient).AnyTimes()

			mockCloudFactory = mock_cloud.NewMockFactory(mockCtrl)

			mockBlobstoreFactory = mock_blobstore.NewMockFactory(mockCtrl)
			mockBlobstore = mock_blobstore.NewMockBlobstore(mockCtrl)
			mockBlobstoreFactory.EXPECT().Create(mbusURL).Return(mockBlobstore, nil).AnyTimes()

			mockVMManagerFactory = mock_vm.NewMockManagerFactory(mockCtrl)
			fakeVMManager = fakebivm.NewFakeManager()
			mockVMManagerFactory.EXPECT().NewManager(gomock.Any(), mockAgentClient).Return(fakeVMManager).AnyTimes()

			fakeStemcellExtractor = fakebistemcell.NewFakeExtractor()
			mockStemcellManager = mock_stemcell.NewMockManager(mockCtrl)
			fakeStemcellManagerFactory = fakebistemcell.NewFakeManagerFactory()

			fakeReleaseSetParser = fakebirelsetmanifest.NewFakeParser()
			fakeInstallationParser = fakebiinstallmanifest.NewFakeParser()
			fakeDeploymentParser = fakebideplmanifest.NewFakeParser()

			mockLegacyDeploymentStateMigrator = mock_config.NewMockLegacyDeploymentStateMigrator(mockCtrl)

			configUUIDGenerator = &fakeuuid.FakeGenerator{}
			configUUIDGenerator.GeneratedUUID = directorID
			setupDeploymentStateService = biconfig.NewFileSystemDeploymentStateService(fakeFs, configUUIDGenerator, logger, biconfig.DeploymentStatePath(deploymentManifestPath))

			fakeDeploymentValidator = fakebideplval.NewFakeValidator()

			fakeStage = fakebiui.NewFakeStage()

			sha1Calculator = crypto.NewSha1Calculator(fakeFs)
			fakeUUIDGenerator = &fakeuuid.FakeGenerator{}
开发者ID:hanzhefeng,项目名称:bosh-init,代码行数:66,代码来源:deploy_cmd_test.go

示例9:

				&fakeui.PerformCall{
					Name:  "installing CPI",
					Stage: fakeui.NewFakeStage(),
				},
			))
		})

		It("cleans up the installation afterwards", func() {
			cpiInstaller := release.CpiInstaller{
				InstallerFactory: mockInstallerFactory,
			}

			cleanupCalled := false
			expectInstall.Return(installation, nil)
			expectCleanup.Times(1).Do(func(_ biinstallation.Installation) {
				cleanupCalled = true
			})
			err := cpiInstaller.WithInstalledCpiRelease(installationManifest, target, installStage, func(installation biinstallation.Installation) error {
				Expect(cleanupCalled).To(BeFalse())
				return nil
			})
			Expect(err).ToNot(HaveOccurred())
		})

		It("creates a stage for the cleanup", func() {
			cpiInstaller := release.CpiInstaller{
				InstallerFactory: mockInstallerFactory,
			}
			expectInstall.Return(installation, nil)

			err := cpiInstaller.WithInstalledCpiRelease(installationManifest, target, installStage, func(installation biinstallation.Installation) error {
开发者ID:vestel,项目名称:bosh-init,代码行数:31,代码来源:installer_test.go

示例10:

		compiledPackageRecord1 := bistatepkg.CompiledPackageRecord{
			BlobID:   "fake-compiled-package-blobstore-id-1",
			BlobSHA1: "fake-compiled-package-sha1-1",
		}
		expectCompilePkg1 = mockPackageCompiler.EXPECT().Compile(releasePackage1).Return(compiledPackageRecord1, false, nil).AnyTimes()

		compiledPackageRecord2 := bistatepkg.CompiledPackageRecord{
			BlobID:   "fake-compiled-package-blobstore-id-2",
			BlobSHA1: "fake-compiled-package-sha1-2",
		}
		expectCompilePkg2 = mockPackageCompiler.EXPECT().Compile(releasePackage2).Return(compiledPackageRecord2, false, nil).AnyTimes()
	})

	It("compiles all the job dependencies (packages) such that no package is compiled before its dependencies", func() {
		gomock.InOrder(
			expectCompilePkg1.Times(1),
			expectCompilePkg2.Times(1),
		)

		_, err := dependencyCompiler.Compile(releaseJobs, fakeStage)
		Expect(err).ToNot(HaveOccurred())
	})

	It("returns references to the compiled packages", func() {
		compiledPackageRefs, err := dependencyCompiler.Compile(releaseJobs, fakeStage)
		Expect(err).ToNot(HaveOccurred())

		Expect(compiledPackageRefs).To(Equal([]CompiledPackageRef{
			{
				Name:        "fake-release-package-name-1",
				Version:     "fake-release-package-fingerprint-1",
开发者ID:hanzhefeng,项目名称:bosh-init,代码行数:31,代码来源:dependency_compiler_test.go


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