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
0
				"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
0
		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())
			}
		})