本文整理汇总了Golang中github.com/cloudfoundry/cli/plugin/fakes.FakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall方法的具体用法?Golang FakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall怎么用?Golang FakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/plugin/fakes.FakeCliConnection
的用法示例。
在下文中一共展示了FakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
})
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",
})
Expect(err).To(Not(BeNil()))
})
It("handles missing key", func() {
_, err := appenv.GetJson("TEST", []string{
示例2:
nil, errors.New("bad things"))
_, err := api.GetOrgs(fakeCliConnection)
Expect(err).ToNot(BeNil())
})
It("populates the url", func() {
fakeCliConnection.CliCommandWithoutTerminalOutputReturns(orgsJSON, nil)
orgs, _ := api.GetOrgs(fakeCliConnection)
org := orgs[0]
Expect(org.URL).To(Equal("/v2/organizations/b1a23fd6-ac8d-4304-a3b4-815745417acd"))
})
It("calls /v2/orgs", func() {
fakeCliConnection.CliCommandWithoutTerminalOutputReturns(orgsJSON, nil)
api.GetOrgs(fakeCliConnection)
args := fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)
Expect(args[1]).To(Equal("/v2/organizations"))
})
})
Describe("Get quota memory limit", func() {
var quotaJSON []string
BeforeEach(func() {
quotaJSON = slurp("test-data/quota.json")
})
It("should return an error when it can't fetch the memory limit", func() {
_, err := api.GetQuotaMemoryLimit(fakeCliConnection, "/v2/somequota")
fakeCliConnection.CliCommandWithoutTerminalOutputReturns(
示例3:
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"))
})
示例4:
ui = &testterm.FakeUI{}
})
It("does not prompt when the user provides the -f flag", func() {
output := io_helpers.CaptureOutput(func() {
wildcardPlugin.Run(fakeCliConnection, []string{"wildcard-delete", "app*", "-f"})
})
Expect(output).To(ContainSubstrings(
[]string{"Deleting app app321"},
[]string{"Deleting app apple_pie"},
))
Expect(output).ToNot(ContainSubstrings(
[]string{"Deleting app spring-music"},
))
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputCallCount()).To(Equal(2))
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)[0]).To(Equal("delete"))
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)[1]).To(Equal("app321"))
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)[2]).To(Equal("-f"))
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(1)[0]).To(Equal("delete"))
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(1)[1]).To(Equal("apple_pie"))
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(1)[2]).To(Equal("-f"))
})
It("does not prompt and deletes all mapped routes when the user provides the -f and -r flag", func() {
output := io_helpers.CaptureOutput(func() {
wildcardPlugin.Run(fakeCliConnection, []string{"wildcard-delete", "app*", "-f", "-r"})
})
Expect(output).To(ContainSubstrings(
[]string{"Deleting app app321 and its mapped routes"},
[]string{"Deleting app apple_pie and its mapped routes"},
))
Expect(output).ToNot(ContainSubstrings(
示例5:
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() {
output := io_helpers.CaptureOutput(func() {
示例6:
SomeString string
}
BeforeEach(func() {
input := []string{"{", `"somestring": "foo"`, "}"}
fakeCliConnection.CliCommandWithoutTerminalOutputReturns(input, nil)
})
It("unmarshals a successful response", func() {
var result MyStruct
err := Curl(fakeCliConnection, &result, "a", "b", "c")
Expect(err).NotTo(HaveOccurred())
Expect(result.SomeString).To(Equal("foo"))
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1))
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)).To(Equal([]string{"curl", "a", "b", "c"}))
})
It("succeeds with no response object", func() {
err := Curl(fakeCliConnection, nil, "a", "b", "c")
Expect(err).NotTo(HaveOccurred())
})
})
Context("when the cli errors", func() {
BeforeEach(func() {
fakeCliConnection.CliCommandWithoutTerminalOutputReturns(nil, errors.New("an error"))
})
It("returns an error", func() {
err := Curl(fakeCliConnection, nil, "a", "b", "c")
示例7:
ghttp.VerifyFormKV("response_type", "code"),
ghttp.VerifyFormKV("client_id", "ssh-oauth-client-id"),
ghttp.VerifyFormKV("grant_type", "authorization_code"),
ghttp.VerifyHeaderKV("authorization", "bearer client-bearer-token"),
ghttp.RespondWith(http.StatusFound, "", http.Header{
"Location": []string{"https://uaa.example.com/login?code=abc123"},
}),
))
})
It("forces the cli to refresh the access token used to acquire the access code", func() {
_, err := credFactory.AuthorizationCode()
Expect(err).NotTo(HaveOccurred())
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1))
Expect(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)).To(ConsistOf("oauth-token"))
Expect(fakeCliConnection.AccessTokenCallCount()).To(Equal(1))
})
It("gets the access code from the token endpoint", func() {
code, err := credFactory.AuthorizationCode()
Expect(err).NotTo(HaveOccurred())
Expect(fakeUAA.ReceivedRequests()).To(HaveLen(1))
Expect(code).To(Equal("abc123"))
})
It("returns an error when the uaa certificate is not valid and certificate validation is enabled", func() {
fakeCliConnection.IsSSLDisabledReturns(false, nil)
_, err := credFactory.AuthorizationCode()
示例8:
fakeCliConnection = &fakes.FakeCliConnection{}
fakeCliConnection.CliCommandWithoutTerminalOutputReturns([]string{""}, nil)
diegoSupport = diego_support.NewDiegoSupport(fakeCliConnection)
})
Describe("SetDiegoFlag", func() {
It("invokes CliCommandWithoutTerminalOutput()", func() {
diegoSupport.SetDiegoFlag("123", false)
Ω(fakeCliConnection.CliCommandWithoutTerminalOutputCallCount()).To(Equal(1))
})
It("calls cli core command 'curl'", func() {
diegoSupport.SetDiegoFlag("123", false)
Ω(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)[0]).To(Equal("curl"))
})
It("hits the /v2/apps endpoint", func() {
diegoSupport.SetDiegoFlag("test-app-guid", false)
Ω(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)[1]).To(Equal("/v2/apps/test-app-guid"))
})
It("uses the 'PUT' method", func() {
diegoSupport.SetDiegoFlag("test-app-guid", false)
Ω(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)[2]).To(Equal("-X"))
Ω(fakeCliConnection.CliCommandWithoutTerminalOutputArgsForCall(0)[3]).To(Equal("PUT"))
})