本文整理汇总了Golang中github.com/cloudfoundry/cli/plugin/fakes.FakeCliConnection.CliCommandWithoutTerminalOutputCallCount方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeCliConnection.CliCommandWithoutTerminalOutputCallCount方法的具体用法?Golang FakeCliConnection.CliCommandWithoutTerminalOutputCallCount怎么用?Golang FakeCliConnection.CliCommandWithoutTerminalOutputCallCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/plugin/fakes.FakeCliConnection
的用法示例。
在下文中一共展示了FakeCliConnection.CliCommandWithoutTerminalOutputCallCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
Context("when retrieving /v2/info is successful", func() {
BeforeEach(func() {
expectedJson = `{
"app_ssh_endpoint": "ssh.example.com:1234",
"app_ssh_host_key_fingerprint": "00:11:22:33:44:55:66:77:88"
}`
fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{expectedJson}, nil)
})
It("returns a populated Info model", func() {
model, err := infoFactory.Get()
Expect(err).NotTo(HaveOccurred())
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1))
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)).To(ConsistOf("curl", "/v2/info"))
Expect(model.SSHEndpoint).To(Equal("ssh.example.com:1234"))
Expect(model.SSHEndpointFingerprint).To(Equal("00:11:22:33:44:55:66:77:88"))
})
})
Context("when retrieving /v2/info fails", func() {
JustBeforeEach(func() {
fakeCliConnection.CliCommandWithoutTerminalOutputReturns(nil, errors.New("woops"))
})
It("fails with an error", func() {
_, err := infoFactory.Get()
Expect(err).To(MatchError("Failed to acquire SSH endpoint info"))
示例2:
Context("when no app name is supplied", func() {
It("returns an error message", func() {
_, err := appenv.GetEnvs(fakeCliConnection, []string{})
Expect(err).To(MatchError("You must specify an app name"))
})
})
Context("when getting vcap_services", func() {
appname := "APP_NAME"
BeforeEach(func() {
fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{"hi"}, nil)
appenv.GetEnvs(fakeCliConnection, []string{"something", appname})
})
It("calls cli", func() {
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputCallCount()).
To(Not(BeZero()))
})
It("requests the correct app envs", func() {
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)).
To(Equal([]string{"env", appname}))
})
})
Context("parsing json app environment data", func() {
It("error handles invalid json", func() {
_, err := appenv.GetJson("TEST", []string{
"foo", "TEST: stuff",
})
示例3:
})
It("Extract Application Name From Command Line Args", func() {
name, err := callCopyEnvCommandPlugin.ExtractAppName([]string{"copyenv"})
Ω(err).Should(MatchError("missing application name"))
name, err = callCopyEnvCommandPlugin.ExtractAppName([]string{"copyenv", "APP_NAME"})
Ω(err).ShouldNot(HaveOccurred())
Ω(name).Should(Equal("APP_NAME"))
})
It("Retrieve Application Environment Variables From Name", func() {
fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{"SOME", "OUTPUT", "COMMAND"}, nil)
output, err := callCopyEnvCommandPlugin.RetrieveAppNameEnv(fakeCliConnection, "APP_NAME")
Ω(err).ShouldNot(HaveOccurred())
Ω(fakeCliConnection.CliCommandWithoutTerminalOutputCallCount()).Should(Equal(1))
Ω(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)).Should(Equal([]string{"env", "APP_NAME"}))
Ω(output).Should(Equal([]string{"SOME", "OUTPUT", "COMMAND"}))
})
It("Return Service Credentials From Appplication Environment", func() {
_, err := callCopyEnvCommandPlugin.ExtractCredentialsJSON("VCAP_SERVICES", []string{""})
Ω(err).Should(MatchError("missing service credentials for application"))
service_creds := []string{"{\"VCAP_SERVICES\":{\"service\": [ { \"credentials\": {} } ]}}"}
b, err := callCopyEnvCommandPlugin.ExtractCredentialsJSON("VCAP_SERVICES", service_creds)
Ω(err).ShouldNot(HaveOccurred())
Ω(string(b[:])).Should(Equal("{\"service\":[{\"credentials\":{}}]}"))
})
It("Print Service Credentials As Shell Variable", func() {