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


Golang FakeProcess.WaitReturns方法代码示例

本文整理汇总了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()))
开发者ID:utako,项目名称:atc,代码行数:29,代码来源:task_step_test.go

示例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{
开发者ID:guanglinlv,项目名称:garden,代码行数:31,代码来源:container_test.go

示例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!"))
				})
			})
开发者ID:julz,项目名称:garden-runc,代码行数:29,代码来源:request_handling_test.go

示例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")
开发者ID:snowsnail,项目名称:executor,代码行数:31,代码来源:checker_test.go

示例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"))
开发者ID:snowsnail,项目名称:executor,代码行数:31,代码来源:run_step_test.go

示例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!",
							}))
						})
					})
				})
			})
开发者ID:pcfdev-forks,项目名称:atc,代码行数:29,代码来源:containers_test.go


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