Beispiel #1
0
			err := cmd.DisableSSH([]string{"disable-ss", "app"}, fakeAppFactory)

			Expect(err).To(MatchError("Invalid usage\n" + cmd.DisableSSHUsage))
		})
	})

	It("disables SSH on an app endpoint", func() {
		fakeAppFactory.GetReturns(myApp, nil)

		err := cmd.DisableSSH([]string{"disable-ssh", "myapp"}, fakeAppFactory)
		Expect(err).NotTo(HaveOccurred())

		Expect(fakeAppFactory.GetCallCount()).To(Equal(1))
		Expect(fakeAppFactory.GetArgsForCall(0)).To(Equal("myapp"))

		Expect(fakeAppFactory.SetBoolCallCount()).To(Equal(1))
		anApp, key, val := fakeAppFactory.SetBoolArgsForCall(0)
		Expect(anApp).To(Equal(myApp))
		Expect(key).To(Equal("enable_ssh"))
		Expect(val).To(BeFalse())
	})

	Context("when retrieving the App fails", func() {
		BeforeEach(func() {
			fakeAppFactory.GetReturns(app.App{}, errors.New("get failed"))
		})

		It("returns an err", func() {
			err := cmd.DisableSSH([]string{"disable-ssh", "myapp"}, fakeAppFactory)
			Expect(err).To(MatchError("get failed"))
			Expect(fakeAppFactory.GetCallCount()).To(Equal(1))