Ω(rpcHandlers.GetAppCallCount()).To(Equal(2)) }) It("sets deigo flag with /v2/apps endpoint", func() { rpcHandlers.GetAppStub = func(_ string, retVal *plugin_models.GetAppModel) error { *retVal = plugin_models.GetAppModel{Guid: "test-app-guid"} return nil } session, err := gexec.Start(exec.Command(validPluginPath, args...), GinkgoWriter, GinkgoWriter) Expect(err).NotTo(HaveOccurred()) session.Wait() Ω(rpcHandlers.CallCoreCommandCallCount()).To(Equal(1)) output, _ := rpcHandlers.CallCoreCommandArgsForCall(0) Ω(output[1]).To(ContainSubstring("v2/apps/test-app-guid")) Ω(output[5]).To(ContainSubstring(`"diego":true`)) }) It("exits with error when GetApp() returns error", func() { rpcHandlers.GetAppStub = func(_ string, retVal *plugin_models.GetAppModel) error { *retVal = plugin_models.GetAppModel{Guid: "test-app-guid"} return errors.New("error in GetApp") } session, err := gexec.Start(exec.Command(validPluginPath, args...), GinkgoWriter, GinkgoWriter) Expect(err).NotTo(HaveOccurred()) session.Wait()
} else { apps.Resources = append(apps.Resources, AppModel{Entity: EntityModel{Name: "app4", State: "STARTED"}}) *retVal = []string{marshal(apps)} } return nil } }) It("follows and curl the next url", func() { args := []string{ts.Port(), "list-apps"} session, err := gexec.Start(exec.Command(validPluginPath, args...), GinkgoWriter, GinkgoWriter) session.Wait() Ω(err).NotTo(HaveOccurred()) Ω(rpcHandlers.CallCoreCommandCallCount()).To(Equal(2)) params, _ := rpcHandlers.CallCoreCommandArgsForCall(0) Ω(params[1]).To(Equal("v2/apps")) params, _ = rpcHandlers.CallCoreCommandArgsForCall(1) Ω(params[1]).To(Equal("v2/apps?page=2")) }) It("traverses through all pages and list all the apps", func() { args := []string{ts.Port(), "list-apps"} session, err := gexec.Start(exec.Command(validPluginPath, args...), GinkgoWriter, GinkgoWriter) session.Wait() Ω(err).NotTo(HaveOccurred()) Ω(session).To(gbytes.Say("app1")) Ω(session).To(gbytes.Say("app2")) Ω(session).To(gbytes.Say("app3")) Ω(session).To(gbytes.Say("app4"))