Exemplo n.º 1
0
			},
			Pidfile: Pidfile{pidfile},
			IO:      nil,
		}
	})

	AfterEach(func() {
		os.Remove(pidfile)
	})

	It("sends the correct process payload to the server", func() {
		err := process.Start()
		Expect(err).ToNot(HaveOccurred())

		Expect(socketConnector.ConnectCallCount()).To(Equal(1))
		Expect(socketConnector.ConnectArgsForCall(0)).To(Equal(process.Spec))
	})

	Context("when the process is interactive (i.e. connected to a TTY)", func() {
		BeforeEach(func() {
			process.Spec.TTY = &garden.TTYSpec{}
		})

		It("makes stdin a raw terminal (because the remote terminal will handle echoing etc.)", func() {
			socketConnector.ConnectReturns([]unix_socket.Fd{FakeFd(0), FakeFd(0)}, 0, nil)

			Expect(process.Start()).To(Succeed())
			Expect(fakeTerm.SetRawTerminalCallCount()).To(Equal(1))
		})

		It("restores the terminal state when the process is cleaned up", func() {
Exemplo n.º 2
0
				Args: []string{"Hello world"},
			},
			IO: nil,
		}
	})

	It("sends the correct process payload to the server", func() {
		err := process.Start()
		Expect(err).ToNot(HaveOccurred())

		payload, err := json.Marshal(&process.Spec)
		Expect(err).ToNot(HaveOccurred())

		Expect(socketConnector.ConnectCallCount()).To(Equal(1))

		socketMessage := socketConnector.ConnectArgsForCall(0)
		Expect(socketMessage.Data).To(Equal(json.RawMessage(payload)))
	})

	Describe("Signalling", func() {
		var (
			signalSent syscall.Signal
		)

		Context("when signalling is enabled", func() {
			BeforeEach(func() {
				response.Pid = 12
				process.ReadSignals = true

				socketConnector.ConnectReturns(response, nil)
				Expect(process.Start()).To(Succeed())