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


Golang FakeCliConnection.CliCommandReturns方法代码示例

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


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

示例1:

	BeforeEach(func() {
		cliConn = &fakes.FakeCliConnection{}
		autopilotPlugin = &AutopilotPlugin{}
	})

	It("displays push usage when push-zdd called with no arguments", func() {
		autopilotPlugin.Run(cliConn, []string{"push-zdd"})

		Ω(cliConn.CliCommandCallCount()).Should(Equal(1))
		args := cliConn.CliCommandArgsForCall(0)
		Ω(args).Should(Equal([]string{"push", "-h"}))
	})

	It("can push an app that already exists", func() {
		cliConn.CliCommandReturns([]string{"myapp and-other-stuff"}, nil)
		output := CaptureOutput(func() {
			autopilotPlugin.Run(cliConn, []string{"push-zdd", "myapp"})
		})

		Expect(len(ActionList)).To(Equal(3))
		Expect(output).To(ContainElement(ContainSubstring("using zero-downtime-deployment")))
	})

	It("can push an app that doesn't exist", func() {
		cliConn.CliCommandReturns([]string{"some-other-app and-other-stuff"}, nil)
		output := CaptureOutput(func() {
			autopilotPlugin.Run(cliConn, []string{"push-zdd", "my-new-app"})
		})

		Expect(len(ActionList)).To(Equal(1))
开发者ID:compozed,项目名称:autopilot,代码行数:30,代码来源:autopilot_test.go

示例2:

		cliConn = &fakes.FakeCliConnection{}
		repo = NewApplicationRepo(cliConn)
	})

	Describe("RenameApplication", func() {
		It("renames the application", func() {
			err := repo.RenameApplication("old-name", "new-name")
			Ω(err).ShouldNot(HaveOccurred())

			Ω(cliConn.CliCommandCallCount()).Should(Equal(1))
			args := cliConn.CliCommandArgsForCall(0)
			Ω(args).Should(Equal([]string{"rename", "old-name", "new-name"}))
		})

		It("returns an error if one occurs", func() {
			cliConn.CliCommandReturns([]string{}, errors.New("no app"))

			err := repo.RenameApplication("old-name", "new-name")
			Ω(err).Should(MatchError("no app"))
		})
	})

	Describe("PushApplication", func() {
		It("pushes an application with both a manifest and a path", func() {
			err := repo.PushApplication([]string{"push", "myapp", "-f", "/path/to/a/manifest.yml", "-p", "/path/to/the/app"})
			Ω(err).ShouldNot(HaveOccurred())

			Ω(cliConn.CliCommandCallCount()).Should(Equal(1))
			args := cliConn.CliCommandArgsForCall(0)
			Ω(args).Should(Equal([]string{
				"push",
开发者ID:xchapter7x,项目名称:autopilot,代码行数:31,代码来源:application_repo_test.go

示例3:

		var fakeCliConnection *fakes.FakeCliConnection
		var callCliCommandPlugin *CliCmd

		BeforeEach(func() {
			fakeCliConnection = &fakes.FakeCliConnection{}
			callCliCommandPlugin = &CliCmd{}
		})

		It("calls the cli command that is passed as an argument", func() {
			io_helpers.CaptureOutput(func() {
				callCliCommandPlugin.Run(fakeCliConnection, []string{"cli-command", "plugins", "arg1"})
			})

			Expect(fakeCliConnection.CliCommandArgsForCall(0)[0]).To(Equal("plugins"))
			Expect(fakeCliConnection.CliCommandArgsForCall(0)[1]).To(Equal("arg1"))
		})

		It("ouputs the text returned by the cli command", func() {
			fakeCliConnection.CliCommandReturns([]string{"Hi", "Mom"}, nil)
			output := io_helpers.CaptureOutput(func() {
				callCliCommandPlugin.Run(fakeCliConnection, []string{"cli-command", "plugins", "arg1"})
			})

			Expect(output[1]).To(Equal("---------- Command output from the plugin ----------"))
			Expect(output[2]).To(Equal("# 0  value:  Hi"))
			Expect(output[3]).To(Equal("# 1  value:  Mom"))
			Expect(output[4]).To(Equal("----------              FIN               -----------"))
		})
	})
})
开发者ID:vframbach,项目名称:cli,代码行数:30,代码来源:call_cli_cmd_test.go


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