本文整理汇总了Golang中github.com/cloudfoundry/cli/plugin/fakes.FakeCliConnection.GetAppsReturns方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeCliConnection.GetAppsReturns方法的具体用法?Golang FakeCliConnection.GetAppsReturns怎么用?Golang FakeCliConnection.GetAppsReturns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/plugin/fakes.FakeCliConnection
的用法示例。
在下文中一共展示了FakeCliConnection.GetAppsReturns方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
fakeCliConnection *fakes.FakeCliConnection
appsList []plugin_models.GetAppsModel
)
Context("When running wildcard-apps", func() {
BeforeEach(func() {
appsList = make([]plugin_models.GetAppsModel, 0)
appsList = append(appsList,
plugin_models.GetAppsModel{"spring-music", "", "", 0, 0, 0, 0, nil},
plugin_models.GetAppsModel{"app321", "", "", 0, 0, 0, 0, nil},
)
fakeCliConnection = &fakes.FakeCliConnection{}
wildcardPlugin = &Wildcard{}
})
Describe("When there are matching apps", func() {
It("prints a table containing only those apps", func() {
fakeCliConnection.GetAppsReturns(appsList, nil)
output := io_helpers.CaptureOutput(func() {
wildcardPlugin.Run(fakeCliConnection, []string{"wildcard-apps", "app*"})
})
Expect(output).To(ContainSubstrings(
[]string{"app321"},
))
Expect(output).ToNot(ContainSubstrings(
[]string{"spring-music"},
))
})
})
Describe("When there are matching apps", func() {
It("prints a table containing only those apps", func() {
fakeCliConnection.GetAppsReturns(appsList, nil)
示例2:
"delete", "app-name",
"-f",
}))
})
It("returns errors from the delete", func() {
cliConn.CliCommandReturns([]string{}, errors.New("bad app"))
err := repo.DeleteApplication("app-name")
Ω(err).Should(MatchError("bad app"))
})
})
Describe("ListApplications", func() {
Context("when we called", func() {
It("then it should call the get apps list api", func() {
err := repo.ListApplications()
Ω(err).ShouldNot(HaveOccurred())
Ω(cliConn.GetAppsCallCount()).Should(Equal(1))
})
})
Context("when the get apps call yields an error", func() {
It("then it should return the errors ", func() {
cliConn.GetAppsReturns(nil, errors.New("bad apps"))
err := repo.ListApplications()
Ω(err).Should(MatchError("bad apps"))
})
})
})
})
示例3:
var (
controlAppName = "myapp"
controlAppNameVenerable = fmt.Sprintf("%s-venerable", controlAppName)
controlCallChain = [][]string{
[]string{"rename", controlAppName, controlAppNameVenerable},
[]string{"push", controlAppName},
[]string{"delete", controlAppNameVenerable, "-f"},
}
controlCallCount = len(controlCallChain)
)
BeforeEach(func() {
cliConn.GetAppsReturns([]plugin_models.GetAppsModel{
plugin_models.GetAppsModel{
Name: controlAppName,
},
plugin_models.GetAppsModel{
Name: "and-other-stuff",
},
}, nil)
autopilotPlugin.Run(cliConn, []string{"push-zdd", controlAppName})
})
It("then it should rename the existing app to venerable", func() {
callCount := cliConn.CliCommandCallCount()
for i := 0; i < callCount; i++ {
called := cliConn.CliCommandArgsForCall(i)
fmt.Println(called)
Ω(true).Should(BeTrue())
}
})