Ejemplo n.º 1
0
		})

		It("runs a remote command", func() {
			fakeDialer.DialReturns(fakeSession, nil)
			fakeSession.StdinPipeReturns(fakeStdin, nil)
			fakeSession.StdoutPipeReturns(fakeStdout, nil)
			fakeSession.StderrPipeReturns(fakeStderr, nil)

			err := secureShell.ConnectToShell("app-name", 2, "/bin/ls", config)
			Expect(err).NotTo(HaveOccurred())

			Expect(fakeSession.ShellCallCount()).To(Equal(0))
			Expect(fakeSession.WaitCallCount()).To(Equal(0))

			Expect(fakeSession.RunCallCount()).To(Equal(1))
			Expect(fakeSession.RunArgsForCall(0)).To(Equal("/bin/ls"))
		})

		It("respects the user's TERM environment variable", func() {
			fakeDialer.DialReturns(fakeSession, nil)
			fakeSession.StdinPipeReturns(fakeStdin, nil)
			fakeSession.StdoutPipeReturns(fakeStdout, nil)
			fakeSession.StderrPipeReturns(fakeStderr, nil)

			os.Setenv("TERM", "term2000")

			err := secureShell.ConnectToShell("app-name", 2, "", config)
			Expect(err).NotTo(HaveOccurred())

			Expect(fakeSession.RequestPtyCallCount()).To(Equal(1))
			termType, _, _, _ := fakeSession.RequestPtyArgsForCall(0)