executor = &fakes.Executor{} namespaceOpener = &fakes.Opener{} containerNS = &fakes.Namespace{NameStub: func() string { return "container ns sentinel" }} namespaceOpener.OpenPathReturns(containerNS, nil) deletor = container.Deletor{ Executor: executor, NamespaceOpener: namespaceOpener, } }) It("should open the container namespace", func() { err := deletor.Delete("some-interface-name", "/path/to/container/namespace", "sandbox-name", "some-vxlan") Expect(err).NotTo(HaveOccurred()) Expect(namespaceOpener.OpenPathCallCount()).To(Equal(1)) Expect(namespaceOpener.OpenPathArgsForCall(0)).To(Equal("/path/to/container/namespace")) }) Context("when opening the container namespace fails", func() { BeforeEach(func() { namespaceOpener.OpenPathReturns(nil, errors.New("POTATO")) }) It("should return a meaningful error", func() { err := deletor.Delete("some-interface-name", "/path/to/container/namespace", "sandbox-name", "some-vxlan") Expect(err).To(MatchError("open container netns: POTATO")) }) }) It("should construct the correct command sequence", func() {