Beispiel #1
0
	)

	BeforeEach(func() {
		withTty = false
		runner = new(fake_runner.FakeRunner)
		ptyOpener = new(fake_ptyopener.FakePTYOpener)

		cmd = exec.Command("foo")
		spawner = &container_daemon.Spawn{
			Runner: runner,
			PTY:    ptyOpener,
		}
	})

	JustBeforeEach(func() {
		returnedFds, returnedErr = spawner.Spawn(cmd, withTty)
	})

	Describe("With a TTY", func() {
		BeforeEach(func() {
			withTty = true
		})

		Context("when a pty cannot be opened", func() {
			BeforeEach(func() {
				ptyOpener.OpenReturns(nil, nil, errors.New("an error"))
			})

			It("returns an error", func() {
				Expect(returnedErr).To(HaveOccurred())
			})
			Runner: runner,
			PTY:    ptyOpener,
		}
	})

	Describe("with a tty", func() {
		var withTty = true

		Context("When starting fails", func() {
			BeforeEach(func() {
				runner.StartReturns(errors.New("failed"))
			})

			It("does not leak files", func() {
				for i := 0; i < 50; i++ {
					spawner.Spawn(exec.Command("foo"), withTty)
				}

				Eventually(openFileCount, "10s").Should(BeNumerically("<=", originalOpenFiles))
			})
		})
	})

	Describe("without a tty", func() {
		var withTty = false

		Context("When starting fails", func() {
			BeforeEach(func() {
				runner.StartReturns(errors.New("failed"))
			})