當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。