Esempio n. 1
0
		spec := gardener.DesiredContainerSpec{Handle: "foo"}
		Expect(czr.Create(spec)).To(Succeed())

		Expect(fakeRepo.CreateCallCount()).To(Equal(1))
		Expect(fakeRepo.CreateArgsForCall(0)).To(Equal(spec))
	})

	Context("when the container exists", func() {
		It("delegates running to the repo", func() {
			anActualContainer := new(fakes.FakeActualContainer)
			fakeRepo.LookupReturns(anActualContainer, nil)

			stdout := gbytes.NewBuffer()
			czr.Run(
				"fishfinger",
				garden.ProcessSpec{Path: "foo"},
				garden.ProcessIO{Stdout: stdout},
			)

			Expect(fakeRepo.LookupArgsForCall(0)).To(Equal("fishfinger"))
			Expect(anActualContainer.RunCallCount()).To(Equal(1))

			spec, io := anActualContainer.RunArgsForCall(0)
			Expect(spec.Path).To(Equal("foo"))
			Expect(io.Stdout).To(Equal(stdout))
		})
	})

	Context("when the container does not exist", func() {
		PIt("returns an error", func() {
		})
Esempio n. 2
0
		})

		Context("when the start check fails", func() {
			It("returns the underlying error", func() {
				fakeStartChecker.CheckStub = func(_ lager.Logger, stdout io.Reader) error {
					return errors.New("I died")
				}

				Expect(containerizer.Create(logger, gardener.DesiredContainerSpec{Handle: "the-handle"})).To(MatchError("I died"))
			})
		})
	})

	Describe("Run", func() {
		It("should ask the execer to exec a process in the container", func() {
			containerizer.Run(logger, "some-handle", garden.ProcessSpec{Path: "hello"}, garden.ProcessIO{})
			Expect(fakeContainerRunner.ExecCallCount()).To(Equal(1))

			_, path, id, spec, _ := fakeContainerRunner.ExecArgsForCall(0)
			Expect(path).To(Equal("/path/to/some-handle"))
			Expect(id).To(Equal("some-handle"))
			Expect(spec.Path).To(Equal("hello"))
		})

		Context("when looking up the container fails", func() {
			It("returns an error", func() {
				fakeDepot.LookupReturns("", errors.New("blam"))
				_, err := containerizer.Run(logger, "some-handle", garden.ProcessSpec{}, garden.ProcessIO{})
				Expect(err).To(HaveOccurred())
			})