コード例 #1
0
ファイル: ssh_test.go プロジェクト: sykesm/diego-ssh
		var connectErr error
		var opts *options.SSHOptions

		BeforeEach(func() {
			opts = &options.SSHOptions{
				AppName: "app-1",
			}
		})

		JustBeforeEach(func() {
			connectErr = secureShell.Connect(opts)
		})

		Context("when there is an error getting the app model", func() {
			BeforeEach(func() {
				fakeAppFactory.GetReturns(app.App{}, errors.New("woops"))
			})

			It("returns the error", func() {
				Expect(fakeAppFactory.GetCallCount()).To(Equal(1))
				Expect(connectErr).To(Equal(errors.New("woops")))
			})

			It("does not attempt to acquire endpoint info", func() {
				Expect(fakeInfoFactory.GetCallCount()).To(Equal(0))
			})
		})

		Context("when the app model is successfully acquired", func() {
			BeforeEach(func() {
				fakeAppFactory.GetReturns(app.App{}, nil)
コード例 #2
0
ファイル: disable_ssh_test.go プロジェクト: sykesm/diego-ssh
	Context("validation", func() {
		It("requires an application name", func() {
			err := cmd.DisableSSH([]string{"disable-ssh"}, fakeAppFactory)

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

		It("validates the command name", func() {
			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() {