本文整理汇总了Golang中github.com/cloudfoundry-incubator/garden/fakes.FakeProcess.WaitReturns方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeProcess.WaitReturns方法的具体用法?Golang FakeProcess.WaitReturns怎么用?Golang FakeProcess.WaitReturns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry-incubator/garden/fakes.FakeProcess
的用法示例。
在下文中一共展示了FakeProcess.WaitReturns方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
It("invokes the delegate's Failed callback", func() {
Eventually(process.Wait()).Should(Receive(HaveOccurred()))
Ω(taskDelegate.FailedCallCount()).Should(Equal(1))
err := taskDelegate.FailedArgsForCall(0)
Ω(err).Should(BeAssignableToTypeOf(MissingInputsError{}))
Ω(err.(MissingInputsError).Inputs).Should(ConsistOf("some-other-input"))
})
})
})
Context("when the process exits 0", func() {
BeforeEach(func() {
fakeProcess.WaitReturns(0, nil)
})
It("saves the exit status property", func() {
Eventually(process.Wait()).Should(Receive(BeNil()))
Ω(fakeContainer.SetPropertyCallCount()).Should(Equal(2))
name, value := fakeContainer.SetPropertyArgsForCall(1)
Ω(name).Should(Equal("concourse:exit-status"))
Ω(value).Should(Equal("0"))
})
It("is successful", func() {
Eventually(process.Wait()).Should(Receive(BeNil()))
示例2:
})
It("returns the error", func() {
_, err := container.CurrentMemoryLimits()
Ω(err).Should(Equal(disaster))
})
})
})
Describe("Run", func() {
It("sends a run request and returns the process id and a stream", func() {
fakeConnection.RunStub = func(handle string, spec garden.ProcessSpec, io garden.ProcessIO) (garden.Process, error) {
process := new(wfakes.FakeProcess)
process.IDReturns(42)
process.WaitReturns(123, nil)
go func() {
defer GinkgoRecover()
_, err := fmt.Fprintf(io.Stdout, "stdout data")
Ω(err).ShouldNot(HaveOccurred())
_, err = fmt.Fprintf(io.Stderr, "stderr data")
Ω(err).ShouldNot(HaveOccurred())
}()
return process, nil
}
spec := garden.ProcessSpec{
示例3:
Context("when the container is not found", func() {
It("fails", func() {
serverBackend.LookupReturns(nil, errors.New("not found"))
_, err := container.Attach(123, garden.ProcessIO{})
Ω(err).Should(HaveOccurred())
})
})
Context("when waiting on the process fails server-side", func() {
BeforeEach(func() {
fakeContainer.AttachStub = func(id uint32, io garden.ProcessIO) (garden.Process, error) {
process := new(fakes.FakeProcess)
process.IDReturns(42)
process.WaitReturns(0, errors.New("oh no!"))
return process, nil
}
})
It("bubbles the error up", func() {
process, err := container.Attach(42, garden.ProcessIO{})
Ω(err).ShouldNot(HaveOccurred())
_, err = process.Wait()
Ω(err).Should(HaveOccurred())
Ω(err.Error()).Should(ContainSubstring("oh no!"))
})
})
示例4:
var oldContainer *gardenFakes.FakeContainer
var fakeProcess *gardenFakes.FakeProcess
BeforeEach(func() {
fakeContainer = &gardenFakes.FakeContainer{}
oldContainer = &gardenFakes.FakeContainer{}
oldContainer.HandleReturns("old-guid")
fakeProcess = &gardenFakes.FakeProcess{}
})
Context("When garden is healthy", func() {
BeforeEach(func() {
gardenClient.CreateReturns(fakeContainer, nil)
gardenClient.ContainersReturns([]garden.Container{oldContainer}, nil)
fakeContainer.RunReturns(fakeProcess, nil)
fakeProcess.WaitReturns(0, nil)
})
It("drives a container lifecycle", func() {
err := gardenChecker.Healthcheck(logger)
By("Fetching any pre-existing healthcheck containers")
Expect(gardenClient.ContainersCallCount()).To(Equal(1))
By("Deleting all pre-existing-containers")
//call count is two because we also expect to destroy the container we create
Expect(gardenClient.DestroyCallCount()).To(Equal(2))
guid := gardenClient.DestroyArgsForCall(0)
Expect(guid).To(Equal("old-guid"))
By("Creates the container")
示例5:
portMappings,
exportNetworkEnvVars,
fakeClock,
)
})
Describe("Perform", func() {
var stepErr error
JustBeforeEach(func() {
stepErr = step.Perform()
})
Context("when the script succeeds", func() {
BeforeEach(func() {
spawnedProcess.WaitReturns(0, nil)
})
It("does not return an error", func() {
Expect(stepErr).NotTo(HaveOccurred())
})
It("executes the command in the passed-in container", func() {
ranHandle, spec, _ := gardenClient.Connection.RunArgsForCall(0)
Expect(ranHandle).To(Equal(handle))
Expect(spec.Path).To(Equal("sudo"))
Expect(spec.Args).To(Equal([]string{"reboot"}))
Expect(spec.Dir).To(Equal("/some-dir"))
Expect(*spec.Limits.Nofile).To(BeNumerically("==", fileDescriptorLimit))
Expect(spec.Env).To(ContainElement("A=1"))
Expect(spec.Env).To(ContainElement("B=2"))
示例6:
It("forwards the error to the response", func() {
var hijackOutput atc.HijackOutput
err := conn.ReadJSON(&hijackOutput)
Expect(err).NotTo(HaveOccurred())
Expect(hijackOutput).To(Equal(atc.HijackOutput{
Error: "oh no!",
}))
})
})
})
Context("when waiting on the process fails", func() {
BeforeEach(func() {
fakeProcess.WaitReturns(0, errors.New("oh no!"))
})
It("forwards the error to the response", func() {
var hijackOutput atc.HijackOutput
err := conn.ReadJSON(&hijackOutput)
Expect(err).NotTo(HaveOccurred())
Expect(hijackOutput).To(Equal(atc.HijackOutput{
Error: "oh no!",
}))
})
})
})
})