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


Golang FakeProcess.WaitStub方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry-incubator/garden/fakes.FakeProcess.WaitStub方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeProcess.WaitStub方法的具体用法?Golang FakeProcess.WaitStub怎么用?Golang FakeProcess.WaitStub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry-incubator/garden/fakes.FakeProcess的用法示例。


在下文中一共展示了FakeProcess.WaitStub方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

						It("invokes the delegate's Failed callback", func() {
							Eventually(process.Wait()).Should(Receive(Equal(disaster)))
							Ω(taskDelegate.FailedCallCount()).Should(Equal(1))
							Ω(taskDelegate.FailedArgsForCall(0)).Should(Equal(disaster))
						})
					})

					Describe("signalling", func() {
						var stopped chan struct{}

						BeforeEach(func() {
							stopped = make(chan struct{})

							fakeProcess.WaitStub = func() (int, error) {
								<-stopped
								return 128 + 15, nil
							}

							fakeContainer.StopStub = func(bool) error {
								close(stopped)
								return nil
							}
						})

						It("stops the container", func() {
							process.Signal(os.Interrupt)
							Eventually(process.Wait()).Should(Receive(Equal(ErrInterrupted)))

							Ω(fakeContainer.StopCallCount()).Should(Equal(1))
						})
					})
开发者ID:utako,项目名称:atc,代码行数:31,代码来源:task_step_test.go

示例2:

	)

	BeforeEach(func() {
		source = atc.Source{"some": "source"}
		params = atc.Params{"some": "params"}
		fakeArtifactSource = new(fakes.FakeArtifactSource)

		outScriptStdout = "{}"
		outScriptStderr = ""
		outScriptExitStatus = 0
		runOutError = nil

		outScriptProcess = new(gfakes.FakeProcess)
		outScriptProcess.IDReturns(42)
		outScriptProcess.WaitStub = func() (int, error) {
			return outScriptExitStatus, nil
		}

		stdoutBuf = gbytes.NewBuffer()
		stderrBuf = gbytes.NewBuffer()

		ioConfig = IOConfig{
			Stdout: stdoutBuf,
			Stderr: stderrBuf,
		}
	})

	JustBeforeEach(func() {
		fakeContainer.RunStub = func(spec garden.ProcessSpec, io garden.ProcessIO) (garden.Process, error) {
			if runOutError != nil {
				return nil, runOutError
开发者ID:utako,项目名称:atc,代码行数:31,代码来源:resource_out_test.go

示例3:

							in, err := ioutil.ReadAll(io.Stdin)
							Ω(err).ShouldNot(HaveOccurred())

							_, err = fmt.Fprintf(io.Stdout, "mirrored %s", string(in))
							Ω(err).ShouldNot(HaveOccurred())

							_, err = fmt.Fprintf(io.Stderr, "stderr data")
							Ω(err).ShouldNot(HaveOccurred())
						}()

						process := new(fakes.FakeProcess)

						process.IDReturns(42)

						process.WaitStub = func() (int, error) {
							writing.Wait()
							return 123, nil
						}

						return process, nil
					}
				})

				It("responds with a ProcessPayload for every chunk", func() {
					stdout := gbytes.NewBuffer()
					stderr := gbytes.NewBuffer()

					processIO := garden.ProcessIO{
						Stdin:  bytes.NewBufferString("stdin data"),
						Stdout: stdout,
						Stderr: stderr,
					}
开发者ID:julz,项目名称:garden-runc,代码行数:32,代码来源:request_handling_test.go

示例4:

		checkResult []atc.Version
		checkErr    error
	)

	BeforeEach(func() {
		source = atc.Source{"some": "source"}
		version = atc.Version{"some": "version"}

		checkScriptStdout = "[]"
		checkScriptStderr = ""
		checkScriptExitStatus = 0
		runCheckError = nil

		checkScriptProcess = new(gfakes.FakeProcess)
		checkScriptProcess.WaitStub = func() (int, error) {
			return checkScriptExitStatus, nil
		}

		checkResult = nil
		checkErr = nil
	})

	JustBeforeEach(func() {
		fakeContainer.RunStub = func(spec garden.ProcessSpec, io garden.ProcessIO) (garden.Process, error) {
			if runCheckError != nil {
				return nil, runCheckError
			}

			_, err := io.Stdout.Write([]byte(checkScriptStdout))
			Expect(err).NotTo(HaveOccurred())
开发者ID:pcfdev-forks,项目名称:atc,代码行数:30,代码来源:resource_check_test.go

示例5:

						defer writing.Done()
						defer GinkgoRecover()

						_, err := fmt.Fprintf(io.Stdout, "hi out\n")
						Expect(err).ToNot(HaveOccurred())

						_, err = fmt.Fprintf(io.Stderr, "hi err\n")
						Expect(err).ToNot(HaveOccurred())
					}()

					process := new(wfakes.FakeProcess)

					process.IDReturns(processID)

					process.WaitStub = func() (int, error) {
						writing.Wait()
						return 123, nil
					}

					return process, nil
				}
			})

			It("streams stderr and stdout and exit status", func() {
				stdout := gbytes.NewBuffer()
				stderr := gbytes.NewBuffer()

				process, err := container.Run(garden.ProcessSpec{
					User: "alice",
					Path: "/some/script",
				}, garden.ProcessIO{
					Stdout: stdout,
开发者ID:guanglinlv,项目名称:garden-linux,代码行数:32,代码来源:running_test.go

示例6:

		Describe("emitting logs", func() {
			var stdoutBuffer, stderrBuffer *gbytes.Buffer

			BeforeEach(func() {
				stdoutBuffer = gbytes.NewBuffer()
				stderrBuffer = gbytes.NewBuffer()

				fakeStreamer.StdoutReturns(stdoutBuffer)
				fakeStreamer.StderrReturns(stderrBuffer)

				spawnedProcess.WaitStub = func() (int, error) {
					_, _, io := gardenClient.Connection.RunArgsForCall(0)

					_, err := io.Stdout.Write([]byte("hi out"))
					Expect(err).NotTo(HaveOccurred())

					_, err = io.Stderr.Write([]byte("hi err"))
					Expect(err).NotTo(HaveOccurred())

					return 34, nil
				}
			})

			It("emits the output chunks as they come in", func() {
				Expect(stdoutBuffer).To(gbytes.Say("hi out"))
				Expect(stderrBuffer).To(gbytes.Say("hi err"))
			})

			It("should flush the output when the code exits", func() {
				Expect(fakeStreamer.FlushCallCount()).To(Equal(1))
			})
开发者ID:snowsnail,项目名称:executor,代码行数:31,代码来源:run_step_test.go

示例7:

				Ω(handle).Should(Equal("la-contineur"))
				Ω(processID).Should(Equal(uint32(6)))
				Ω(calledProcessIO).Should(Equal(processIO))
			})

			Describe("the process", func() {
				Describe("Wait", func() {
					BeforeEach(func() {
						errs := make(chan error, 1)
						errs <- fmt.Errorf("connection: decode failed: %s", io.EOF)
						close(errs)

						fakeProcess.WaitStub = func() (int, error) {
							err := <-errs
							if err == nil {
								return 42, nil
							}

							return 0, err
						}
					})

					It("reattaches on EOF", func() {
						result, err := process.Wait()
						Ω(err).ShouldNot(HaveOccurred())
						Ω(result).Should(Equal(42))

						Ω(innerConnection.AttachCallCount()).Should(Equal(2))
						handle, processID, calledProcessIO := innerConnection.AttachArgsForCall(1)
						Ω(handle).Should(Equal("la-contineur"))
						Ω(processID).Should(Equal(uint32(6)))
						Ω(calledProcessIO).Should(Equal(processIO))
开发者ID:utako,项目名称:atc,代码行数:32,代码来源:retryable_garden_connection_test.go

示例8:

				Eventually(created).Should(Receive())

				err := apiClient.Ping()
				Ω(err).Should(HaveOccurred())
			})
		})

		Context("when a Run request is in-flight", func() {
			It("does not wait for the request to complete", func(done Done) {
				fakeContainer := new(fakes.FakeContainer)

				fakeContainer.RunStub = func(spec garden.ProcessSpec, io garden.ProcessIO) (garden.Process, error) {
					process := new(fakes.FakeProcess)

					process.WaitStub = func() (int, error) {
						time.Sleep(time.Minute)
						return 0, nil
					}

					go func() {
						defer GinkgoRecover()

						_, err := io.Stdout.Write([]byte("msg 1\n"))
						Ω(err).ShouldNot(HaveOccurred())

						time.Sleep(time.Minute)

						_, err = io.Stdout.Write([]byte("msg 2\n"))
						Ω(err).ShouldNot(HaveOccurred())
					}()

					return process, nil
开发者ID:nagyistoce,项目名称:garden,代码行数:32,代码来源:server_test.go

示例9:

					})
				})

				Context("when running the process succeeds", func() {
					var (
						fakeProcess *gfakes.FakeProcess
						processExit chan int
					)

					BeforeEach(func() {
						exit := make(chan int)
						processExit = exit

						fakeProcess = new(gfakes.FakeProcess)
						fakeProcess.WaitStub = func() (int, error) {
							return <-exit, nil
						}

						fakeContainer.RunReturns(fakeProcess, nil)
					})

					AfterEach(func() {
						close(processExit)
					})

					It("hijacks the build", func() {
						Eventually(fakeContainer.RunCallCount).Should(Equal(1))

						_, lookedUpID := fakeWorkerClient.LookupContainerArgsForCall(0)
						Expect(lookedUpID).To(Equal(handle))
开发者ID:pcfdev-forks,项目名称:atc,代码行数:30,代码来源:containers_test.go


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