}) Context("when there are no veth devices in the sandbox", func() { It("removes the vxlan device in the sandbox namespace", func() { sandboxNS.ExecuteStub = func(callback func(ns *os.File) error) error { Expect(linkFactory.DeleteLinkByNameCallCount()).To(Equal(0)) err := callback(nil) Expect(linkFactory.DeleteLinkByNameCallCount()).To(Equal(1)) return err } err := cleanupSandboxCommand.Execute(context) Expect(err).NotTo(HaveOccurred()) Expect(sandboxNS.ExecuteCallCount()).To(Equal(1)) Expect(linkFactory.DeleteLinkByNameArgsForCall(0)).To(Equal("some-vxlan")) }) It("destroys the sandbox", func() { err := cleanupSandboxCommand.Execute(context) Expect(err).NotTo(HaveOccurred()) Expect(sandboxRepo.DestroyCallCount()).To(Equal(1)) Expect(sandboxRepo.DestroyArgsForCall(0)).To(Equal("sandbox-name")) }) Context("when destroy fails with AlreadyDestroyedError", func() { BeforeEach(func() { sandboxRepo.DestroyReturns(sandbox.AlreadyDestroyedError) })