本文整理汇总了Golang中github.com/concourse/atc/worker/fakes.FakeWorker.CreateContainerCallCount方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeWorker.CreateContainerCallCount方法的具体用法?Golang FakeWorker.CreateContainerCallCount怎么用?Golang FakeWorker.CreateContainerCallCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/concourse/atc/worker/fakes.FakeWorker
的用法示例。
在下文中一共展示了FakeWorker.CreateContainerCallCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
Expect(actualResourceTypes).To(Equal(resourceTypes))
Expect(workerC.SatisfyingCallCount()).To(Equal(1))
actualSpec, actualResourceTypes = workerC.SatisfyingArgsForCall(0)
Expect(actualSpec).To(Equal(spec.WorkerSpec()))
Expect(actualResourceTypes).To(Equal(resourceTypes))
})
It("creates using a random worker", func() {
for i := 1; i < 100; i++ { // account for initial create in JustBefore
createdContainer, createErr := pool.CreateContainer(logger, nil, fakeImageFetchingDelegate, id, Metadata{}, spec, resourceTypes)
Expect(createErr).NotTo(HaveOccurred())
Expect(createdContainer).To(Equal(fakeContainer))
}
Expect(workerA.CreateContainerCallCount()).To(BeNumerically("~", workerB.CreateContainerCallCount(), 50))
Expect(workerC.CreateContainerCallCount()).To(BeZero())
})
Context("when creating the container fails", func() {
disaster := errors.New("nope")
BeforeEach(func() {
workerA.CreateContainerReturns(nil, disaster)
workerB.CreateContainerReturns(nil, disaster)
})
It("returns the error", func() {
Expect(createErr).To(Equal(disaster))
})
})
示例2:
It("looked for the sources on the correct worker", func() {
Expect(inputSource1.VolumeOnCallCount()).To(Equal(1))
actualWorker := inputSource1.VolumeOnArgsForCall(0)
Expect(actualWorker).To(Equal(satisfyingWorker))
Expect(inputSource2.VolumeOnCallCount()).To(Equal(1))
actualWorker = inputSource2.VolumeOnArgsForCall(0)
Expect(actualWorker).To(Equal(satisfyingWorker))
Expect(inputSource3.VolumeOnCallCount()).To(Equal(1))
actualWorker = inputSource3.VolumeOnArgsForCall(0)
Expect(actualWorker).To(Equal(satisfyingWorker))
})
It("creates the container with the cache volume", func() {
Expect(satisfyingWorker.CreateContainerCallCount()).To(Equal(1))
_, id, spec := satisfyingWorker.CreateContainerArgsForCall(0)
Expect(id).To(Equal(session.ID))
resourceSpec := spec.(worker.ResourceTypeContainerSpec)
Expect(resourceSpec.Type).To(Equal(string(initType)))
Expect(resourceSpec.Env).To(Equal([]string{"a=1", "b=2"}))
Expect(resourceSpec.Ephemeral).To(BeTrue())
Expect(resourceSpec.Tags).To(ConsistOf("resource", "tags"))
Expect(resourceSpec.Mounts).To(ConsistOf([]worker.VolumeMount{
{
Volume: inputVolume1,
MountPath: "/tmp/build/put/source-1-name",
},
{
示例3:
Ω(workerB.SatisfiesCallCount()).Should(Equal(1))
Ω(workerB.SatisfiesArgsForCall(0)).Should(Equal(spec))
Ω(workerC.SatisfiesCallCount()).Should(Equal(1))
Ω(workerC.SatisfiesArgsForCall(0)).Should(Equal(spec))
})
It("creates using a random worker", func() {
for i := 1; i < 100; i++ { // account for initial create in JustBefore
createdContainer, createErr := pool.CreateContainer(id, spec)
Ω(createErr).ShouldNot(HaveOccurred())
Ω(createdContainer).Should(Equal(fakeContainer))
}
Ω(workerA.CreateContainerCallCount()).Should(BeNumerically("~", workerB.CreateContainerCallCount(), 50))
Ω(workerC.CreateContainerCallCount()).Should(BeZero())
})
Context("when creating the container fails", func() {
disaster := errors.New("nope")
BeforeEach(func() {
workerA.CreateContainerReturns(nil, disaster)
workerB.CreateContainerReturns(nil, disaster)
})
It("returns the error", func() {
Ω(createErr).Should(Equal(disaster))
})
})