Esempio n. 1
0
		Context("when a request is received", func() {
			BeforeEach(func() {
				request := &ssh.Request{Type: "test", WantReply: false, Payload: []byte("test-data")}
				reqChan <- request
				reqChan <- request
			})

			AfterEach(func() {
				close(reqChan)
			})

			It("forwards requests from the channel to the connection", func() {
				Eventually(sshConn.SendRequestCallCount).Should(Equal(2))
				Consistently(sshConn.SendRequestCallCount).Should(Equal(2))

				reqType, wantReply, payload := sshConn.SendRequestArgsForCall(0)
				Expect(reqType).To(Equal("test"))
				Expect(wantReply).To(BeFalse())
				Expect(payload).To(Equal([]byte("test-data")))

				reqType, wantReply, payload = sshConn.SendRequestArgsForCall(1)
				Expect(reqType).To(Equal("test"))
				Expect(wantReply).To(BeFalse())
				Expect(payload).To(Equal([]byte("test-data")))
			})
		})

		Context("when SendRequest fails", func() {
			BeforeEach(func() {
				callCount := 0
				sshConn.SendRequestStub = func(rt string, wr bool, p []byte) (bool, []byte, error) {