ns.FdReturns(999) ns.NameReturns("target-namespace") sbox.NamespaceReturns(ns) moveLink = commands.MoveLink{ Name: "link-name", SandboxName: "sandbox-name", } }) It("gets the sandbox from the repository", func() { err := moveLink.Execute(context) Expect(err).NotTo(HaveOccurred()) Expect(sandboxRepository.GetCallCount()).To(Equal(1)) Expect(sandboxRepository.GetArgsForCall(0)).To(Equal("sandbox-name")) }) It("moves the link to the target namespace", func() { err := moveLink.Execute(context) Expect(err).NotTo(HaveOccurred()) Expect(linkFactory.SetNamespaceCallCount()).To(Equal(1)) name, fd := linkFactory.SetNamespaceArgsForCall(0) Expect(name).To(Equal("link-name")) Expect(fd).To(BeEquivalentTo(999)) }) Context("when getting the sandbox fails", func() { BeforeEach(func() {
sandboxExists = conditions.SandboxExists{ Name: "some-sandbox", } }) Context("when the namespace exists", func() { BeforeEach(func() { repo.GetReturns(&fakes.Sandbox{}, nil) }) It("returns true", func() { satisfied, err := sandboxExists.Satisfied(context) Expect(err).NotTo(HaveOccurred()) Expect(satisfied).To(BeTrue()) Expect(repo.GetCallCount()).To(Equal(1)) Expect(repo.GetArgsForCall(0)).To(Equal("some-sandbox")) }) }) Context("when the namespace does not exist", func() { BeforeEach(func() { repo.GetReturns(nil, sandbox.NotFoundError) }) It("returns false", func() { satisfied, err := sandboxExists.Satisfied(context) Expect(err).NotTo(HaveOccurred()) Expect(satisfied).To(BeFalse()) Expect(repo.GetCallCount()).To(Equal(1))