當前位置: 首頁>>代碼示例>>Golang>>正文


Golang fakes.FakeProcess類代碼示例

本文整理匯總了Golang中github.com/cloudfoundry-incubator/garden/fakes.FakeProcess的典型用法代碼示例。如果您正苦於以下問題:Golang FakeProcess類的具體用法?Golang FakeProcess怎麽用?Golang FakeProcess使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FakeProcess類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

						Platform: "some-platform",
						Tags:     []string{"config", "tags"},
						Image:    "some-image",
						Params:   map[string]string{"SOME": "params"},
						Run: atc.TaskRunConfig{
							Path: "ls",
							Args: []string{"some", "args"},
						},
					}

					configSource.FetchConfigReturns(fetchedConfig, nil)
				})

				Context("when creating the task's container works", func() {
					var (
						fakeContainer *wfakes.FakeContainer
						fakeProcess   *gfakes.FakeProcess
					)

					BeforeEach(func() {
						fakeContainer = new(wfakes.FakeContainer)
						fakeContainer.HandleReturns("some-handle")
						fakeWorkerClient.CreateContainerReturns(fakeContainer, nil)

						fakeProcess = new(gfakes.FakeProcess)
						fakeProcess.IDReturns(42)
						fakeContainer.RunReturns(fakeProcess, nil)

						fakeContainer.StreamInReturns(nil)
					})

					Describe("before having created the container", func() {
開發者ID:utako,項目名稱:atc,代碼行數:32,代碼來源:task_step_test.go

示例2:

	"github.com/concourse/atc"
	. "github.com/concourse/atc/resource"
	"github.com/concourse/atc/resource/fakes"
)

var _ = Describe("Resource Out", func() {
	var (
		source             atc.Source
		params             atc.Params
		fakeArtifactSource *fakes.FakeArtifactSource

		outScriptStdout     string
		outScriptStderr     string
		outScriptExitStatus int
		runOutError         error

		outScriptProcess *gfakes.FakeProcess

		versionedSource VersionedSource
		outProcess      ifrit.Process

		ioConfig  IOConfig
		stdoutBuf *gbytes.Buffer
		stderrBuf *gbytes.Buffer
	)

	BeforeEach(func() {
		source = atc.Source{"some": "source"}
		params = atc.Params{"some": "params"}
		fakeArtifactSource = new(fakes.FakeArtifactSource)
開發者ID:utako,項目名稱:atc,代碼行數:30,代碼來源:resource_out_test.go

示例3:

			_, _, err = container.NetIn(1235, 5679)
			Expect(err).ToNot(HaveOccurred())

			info, err := container.Info()
			Expect(err).ToNot(HaveOccurred())
			Expect(info.MappedPorts).To(Equal([]garden.PortMapping{
				{HostPort: 1234, ContainerPort: 5678},
				{HostPort: 1235, ContainerPort: 5679},
			}))

		})

		Context("with running processes", func() {
			JustBeforeEach(func() {
				p1 := new(wfakes.FakeProcess)
				p1.IDReturns(1)

				p2 := new(wfakes.FakeProcess)
				p2.IDReturns(2)

				p3 := new(wfakes.FakeProcess)
				p3.IDReturns(3)

				fakeProcessTracker.ActiveProcessesReturns([]garden.Process{p1, p2, p3})
			})

			It("returns their process IDs", func() {
				info, err := container.Info()
				Expect(err).ToNot(HaveOccurred())
				Expect(info.ProcessIDs).To(Equal([]uint32{1, 2, 3}))
開發者ID:guanglinlv,項目名稱:garden-linux,代碼行數:30,代碼來源:linux_container_test.go

示例4:

			BeforeEach(func() {
				fakeConnection.CurrentMemoryLimitsReturns(garden.MemoryLimits{}, disaster)
			})

			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
開發者ID:guanglinlv,項目名稱:garden,代碼行數:30,代碼來源:container_test.go

示例5:

	"github.com/cloudfoundry-incubator/garden"
	gfakes "github.com/cloudfoundry-incubator/garden/fakes"
	"github.com/concourse/atc"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Resource Check", func() {
	var (
		source  atc.Source
		version atc.Version

		checkScriptStdout     string
		checkScriptStderr     string
		checkScriptExitStatus int
		runCheckError         error

		checkScriptProcess *gfakes.FakeProcess

		checkResult []atc.Version
		checkErr    error
	)

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

		checkScriptStdout = "[]"
		checkScriptStderr = ""
		checkScriptExitStatus = 0
		runCheckError = nil
開發者ID:pcfdev-forks,項目名稱:atc,代碼行數:32,代碼來源:resource_check_test.go

示例6:

	"github.com/concourse/atc"
	. "github.com/concourse/atc/resource"
)

var _ = Describe("Resource In", func() {
	var (
		source  atc.Source
		params  atc.Params
		version atc.Version

		inScriptStdout     string
		inScriptStderr     string
		inScriptExitStatus int
		runInError         error

		inScriptProcess *gfakes.FakeProcess

		versionedSource VersionedSource
		inProcess       ifrit.Process

		ioConfig  IOConfig
		stdoutBuf *gbytes.Buffer
		stderrBuf *gbytes.Buffer
	)

	BeforeEach(func() {
		source = atc.Source{"some": "source"}
		version = atc.Version{"some": "version"}
		params = atc.Params{"some": "params"}
開發者ID:pcfdev-forks,項目名稱:atc,代碼行數:29,代碼來源:resource_in_test.go

示例7:

							defer GinkgoRecover()

							_, err := fmt.Fprintf(io.Stdout, "stdout data")
							Ω(err).ShouldNot(HaveOccurred())

							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()
開發者ID:julz,項目名稱:garden-runc,代碼行數:31,代碼來源:request_handling_test.go

示例8:

			BeforeEach(func() {
				fakeConnection.CurrentMemoryLimitsReturns(garden.MemoryLimits{}, disaster)
			})

			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("process-handle")
				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
開發者ID:nagyistoce,項目名稱:garden,代碼行數:30,代碼來源:container_test.go

示例9:

				{HostPort: 1235, ContainerPort: 5679},
			}))

		})

		It("should log before and after", func() {
			_, err := container.Info()
			Expect(err).ToNot(HaveOccurred())

			Expect(logger.LogMessages()).To(ContainElement(ContainSubstring("info-starting")))
			Expect(logger.LogMessages()).To(ContainElement(ContainSubstring("info-ended")))
		})

		Context("with running processes", func() {
			JustBeforeEach(func() {
				p1 := new(wfakes.FakeProcess)
				p1.IDReturns("1")

				p2 := new(wfakes.FakeProcess)
				p2.IDReturns("2")

				p3 := new(wfakes.FakeProcess)
				p3.IDReturns("3")

				fakeProcessTracker.ActiveProcessesReturns([]garden.Process{p1, p2, p3})
			})

			It("returns their process IDs", func() {
				info, err := container.Info()
				Expect(err).ToNot(HaveOccurred())
				Expect(info.ProcessIDs).To(Equal([]string{"1", "2", "3"}))
開發者ID:nagyistoce,項目名稱:garden-linux,代碼行數:31,代碼來源:linux_container_test.go

示例10:

		healthcheckSpec = garden.ProcessSpec{
			Path: "/bin/sh",
			Args: []string{"-c", "echo", "hello"},
			User: "vcap",
		}
		logger = lagertest.NewTestLogger("test")
		gardenClient = &gardenFakes.FakeClient{}
		guidGenerator := &fakeguidgen.FakeGenerator{}
		guidGenerator.GuidReturns("abc-123")
		gardenChecker = gardenhealth.NewChecker(rootfsPath, containerOwnerName, 0, healthcheckSpec, gardenClient, guidGenerator)
	})

	Describe("Healthcheck", func() {
		var fakeContainer *gardenFakes.FakeContainer
		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)
			})
開發者ID:snowsnail,項目名稱:executor,代碼行數:31,代碼來源:checker_test.go

示例11:

				fakeProcessTracker.RunStub = func(processID uint32, cmd *exec.Cmd, io garden.ProcessIO, tty *garden.TTYSpec, signaller process_tracker.Signaller) (garden.Process, error) {
					writing := new(sync.WaitGroup)
					writing.Add(1)

					go func() {
						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()
開發者ID:guanglinlv,項目名稱:garden-linux,代碼行數:31,代碼來源:running_test.go

示例12:

)

var _ = Describe("RunAction", func() {
	var step steps.Step

	var runAction models.RunAction
	var fakeStreamer *fake_log_streamer.FakeLogStreamer
	var gardenClient *fakes.FakeGardenClient
	var logger *lagertest.TestLogger
	var fileDescriptorLimit uint64
	var externalIP string
	var portMappings []executor.PortMapping
	var exportNetworkEnvVars bool
	var fakeClock *fakeclock.FakeClock

	var spawnedProcess *gfakes.FakeProcess
	var runError error

	BeforeEach(func() {
		fileDescriptorLimit = 17

		runAction = models.RunAction{
			Path: "sudo",
			Args: []string{"reboot"},
			Dir:  "/some-dir",
			Env: []*models.EnvironmentVariable{
				{Name: "A", Value: "1"},
				{Name: "B", Value: "2"},
			},
			ResourceLimits: &models.ResourceLimits{
				Nofile: &fileDescriptorLimit,
開發者ID:snowsnail,項目名稱:executor,代碼行數:31,代碼來源:run_step_test.go

示例13:

				calledHandle, calledSpec := innerConnection.StreamOutArgsForCall(0)
				Ω(calledHandle).Should(Equal(handle))
				Ω(calledSpec.Path).Should(Equal("/etc/passwd"))
				Ω(calledSpec.User).Should(Equal("admin"))
			})

			It("returns the reader", func() {
				Ω(gotReader).Should(Equal(gbytes.NewBuffer()))
			})
		})
	})

	Describe("Attach", func() {
		var (
			fakeProcess *gfakes.FakeProcess
			process     garden.Process
		)

		processIO := garden.ProcessIO{
			Stdout: gbytes.NewBuffer(),
		}

		BeforeEach(func() {
			fakeProcess = new(gfakes.FakeProcess)
			fakeProcess.IDReturns(6)
		})

		itRetries(func() error {
			var err error
			process, err = conn.Attach("la-contineur", 6, processIO)
			return err
開發者ID:utako,項目名稱:atc,代碼行數:31,代碼來源:retryable_garden_connection_test.go

示例14:

				close(finishCreating)

				Eventually(stopExited).Should(BeClosed())
				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"))
開發者ID:nagyistoce,項目名稱:garden,代碼行數:31,代碼來源:server_test.go

示例15:

				Context("when the request payload is invalid", func() {
					BeforeEach(func() {
						requestPayload = "ß"
					})

					It("closes the connection with an error", func() {
						_, _, err := conn.ReadMessage()

						Expect(websocket.IsCloseError(err, 1003)).To(BeTrue()) // unsupported data
						Expect(err).To(MatchError(ContainSubstring("malformed process spec")))
					})
				})

				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() {
開發者ID:pcfdev-forks,項目名稱:atc,代碼行數:32,代碼來源:containers_test.go


注:本文中的github.com/cloudfoundry-incubator/garden/fakes.FakeProcess類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。