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


Golang FakeCommandRunner.ExecutedCommands方法代码示例

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


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

示例1:

			})

			It("executes the nstar command with the right arguments", func() {
				Expect(fakeCommandRunner).To(HaveExecutedSerially(fake_command_runner.CommandSpec{
					Path: "path-to-nstar",
					Args: []string{
						"path-to-tar",
						"12",
						"some-user",
						"some-path",
					},
				}))
			})

			It("attaches the tarStream reader to stdin", func() {
				Expect(fakeCommandRunner.ExecutedCommands()[0].Stdin).To(Equal(someStream))
			})
		})

		Context("when it fails", func() {
			It("returns the contents of stdout and error on failure", func() {
				fakeCommandRunner.WhenRunning(fake_command_runner.CommandSpec{}, func(cmd *exec.Cmd) error {
					cmd.Stderr.Write([]byte("some error output"))
					cmd.Stdout.Write([]byte("some std output"))
					return errors.New("someerror")
				})

				Expect(nstar.StreamIn(lagertest.NewTestLogger("test"), 12, "some-path", "some-user", someStream)).To(
					MatchError(ContainSubstring("some error output")),
				)
开发者ID:cloudfoundry,项目名称:guardian,代码行数:30,代码来源:nstar_test.go

示例2:

	JustBeforeEach(func() {
		commandRunner.WhenRunning(fake_command_runner.CommandSpec{
			Path: "funC",
		}, func(cmd *exec.Cmd) error {
			logFile, err := os.Create(cmd.Args[3])
			Expect(err).NotTo(HaveOccurred())
			_, err = io.Copy(logFile, bytes.NewReader([]byte(logs)))
			Expect(err).NotTo(HaveOccurred())
			return runcExitStatus
		})
	})

	It("creates the container with runC create", func() {
		Expect(runner.Create(logger, bundlePath, "some-id", garden.ProcessIO{})).To(Succeed())

		Expect(commandRunner.ExecutedCommands()[0].Path).To(Equal("funC"))
		Expect(commandRunner.ExecutedCommands()[0].Args).To(ConsistOf(
			"funC", "--debug", "--log", logFilePath, "create", "--no-new-keyring", "--bundle", bundlePath, "--pid-file", pidFilePath, "some-id",
		))
	})

	Context("when running runc fails", func() {
		BeforeEach(func() {
			runcExitStatus = errors.New("some-error")
		})

		It("returns runc's exit status", func() {
			Expect(runner.Create(logger, bundlePath, "some-id", garden.ProcessIO{})).To(MatchError("runc create: some-error: "))
		})
	})
开发者ID:cloudfoundry,项目名称:guardian,代码行数:30,代码来源:create_test.go

示例3:

	})

	Describe("Create", func() {
		BeforeEach(func() {
			fakeCmdRunnerStdout = "/this-is/your\n"
		})

		It("uses the correct external-image-manager binary", func() {
			_, _, err := externalImageManager.Create(
				logger, "hello", rootfs_provider.Spec{
					RootFS: baseImage,
				},
			)
			Expect(err).ToNot(HaveOccurred())

			Expect(len(fakeCommandRunner.ExecutedCommands())).To(Equal(1))
			imageManagerCmd := fakeCommandRunner.ExecutedCommands()[0]

			Expect(imageManagerCmd.Path).To(Equal("/external-image-manager-bin"))
		})

		It("returns the env variables defined in the image configuration", func() {
			imagePath, err := ioutil.TempDir("", "")
			Expect(err).NotTo(HaveOccurred())
			fakeCmdRunnerStdout = imagePath

			imageConfig := imageplugin.Image{
				Config: imageplugin.ImageConfig{
					Env: []string{"HELLO=there", "PATH=/my-path/bin"},
				},
			}
开发者ID:cloudfoundry,项目名称:guardian,代码行数:31,代码来源:external_image_manager_test.go

示例4:

					Context("when a multiple destination networks are specified", func() {
						It("opens only that IP", func() {
							Expect(subject.PrependFilterRule(garden.NetOutRule{
								Networks: []garden.IPRange{
									{
										Start: net.ParseIP("1.2.3.4"),
									},
									{
										Start: net.ParseIP("2.2.3.4"),
										End:   net.ParseIP("2.2.3.9"),
									},
								},
							})).To(Succeed())

							Expect(fakeRunner.ExecutedCommands()).To(HaveLen(2))
							Expect(fakeRunner).To(HaveExecutedSerially(
								fake_command_runner.CommandSpec{
									Path: "/sbin/iptables",
									Args: []string{"-w", "-I", "foo-bar-baz", "1", "--protocol", "all", "--destination", "1.2.3.4", "--jump", "RETURN"},
								},
								fake_command_runner.CommandSpec{
									Path: "/sbin/iptables",
									Args: []string{"-w", "-I", "foo-bar-baz", "1", "--protocol", "all", "-m", "iprange", "--dst-range", "2.2.3.4-2.2.3.9", "--jump", "RETURN"},
								},
							))
						})
					})

					Context("when a EndIP is specified without a StartIP", func() {
						It("opens only that IP", func() {
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:30,代码来源:iptables_test.go


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