本文整理匯總了Golang中github.com/cloudfoundry/bosh-init/cloud/mocks.MockCloud.EXPECT方法的典型用法代碼示例。如果您正苦於以下問題:Golang MockCloud.EXPECT方法的具體用法?Golang MockCloud.EXPECT怎麽用?Golang MockCloud.EXPECT使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-init/cloud/mocks.MockCloud
的用法示例。
在下文中一共展示了MockCloud.EXPECT方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
It("does not log any stages", func() {
err := deploymentManager.Cleanup(fakeStage)
Expect(err).ToNot(HaveOccurred())
Expect(fakeStage.PerformCalls).To(BeEmpty())
})
})
Context("orphan disk records exist", func() {
BeforeEach(func() {
_, err := diskRepo.Save("orphan-disk-cid", 100, nil)
Expect(err).ToNot(HaveOccurred())
})
It("deletes the unused disks", func() {
mockCloud.EXPECT().DeleteDisk("orphan-disk-cid")
err := deploymentManager.Cleanup(fakeStage)
Expect(err).ToNot(HaveOccurred())
diskRecords, err := diskRepo.All()
Expect(err).ToNot(HaveOccurred())
Expect(diskRecords).To(BeEmpty(), "expected no disk records")
})
It("logs delete stage", func() {
mockCloud.EXPECT().DeleteDisk("orphan-disk-cid")
err := deploymentManager.Cleanup(fakeStage)
Expect(err).ToNot(HaveOccurred())
示例2:
fs,
logger,
doGet,
)
}
var expectDeployFlow = func() {
agentID := "fake-uuid-0"
vmCID := "fake-vm-cid-1"
diskCID := "fake-disk-cid-1"
diskSize := 1024
//TODO: use a real StateBuilder and test mockBlobstore.Add & mockAgentClient.CompilePackage
gomock.InOrder(
mockCloud.EXPECT().CreateStemcell(stemcellImagePath, stemcellCloudProperties).Return(stemcellCID, nil),
mockCloud.EXPECT().CreateVM(agentID, stemcellCID, vmCloudProperties, networkInterfaces, vmEnv).Return(vmCID, nil),
mockCloud.EXPECT().SetVMMetadata(vmCID, gomock.Any()).Return(nil),
mockAgentClient.EXPECT().Ping().Return("any-state", nil),
mockCloud.EXPECT().CreateDisk(diskSize, diskCloudProperties, vmCID).Return(diskCID, nil),
mockCloud.EXPECT().AttachDisk(vmCID, diskCID),
mockAgentClient.EXPECT().MountDisk(diskCID),
mockAgentClient.EXPECT().Stop(),
mockAgentClient.EXPECT().Apply(applySpec),
mockAgentClient.EXPECT().Start(),
mockAgentClient.EXPECT().GetState().Return(agentRunningState, nil),
)
}
示例3:
mockStateBuilderFactory *mock_instance_state.MockBuilderFactory
mockStateBuilder *mock_instance_state.MockBuilder
mockState *mock_instance_state.MockState
mockBlobstore *mock_blobstore.MockBlobstore
fakeStage *fakebiui.FakeStage
deploymentFactory Factory
deployment Deployment
)
var expectNormalFlow = func() {
gomock.InOrder(
mockCloud.EXPECT().HasVM("fake-vm-cid").Return(true, nil),
mockAgentClient.EXPECT().Ping().Return("any-state", nil), // ping to make sure agent is responsive
mockAgentClient.EXPECT().Stop(), // stop all jobs
mockAgentClient.EXPECT().ListDisk().Return([]string{"fake-disk-cid"}, nil), // get mounted disks to be unmounted
mockAgentClient.EXPECT().UnmountDisk("fake-disk-cid"),
mockCloud.EXPECT().DeleteVM("fake-vm-cid"),
mockCloud.EXPECT().DeleteDisk("fake-disk-cid"),
mockCloud.EXPECT().DeleteStemcell("fake-stemcell-cid"),
)
}
var allowApplySpecToBeCreated = func() {
jobName := "fake-job-name"
jobIndex := 0
applySpec := bias.ApplySpec{