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() { err := deletor.Delete("some-interface-name", "/path/to/container/namespace", "sandbox-name", "some-vxlan")
NetworkID: "some-crazy-network-id", ContainerNsPath: "/some/container/ns/path", ContainerID: "123456789012345", InterfaceName: "container-link", VNI: 99, IPAMResult: ipamResult, App: "some-app-guid", } }) It("should open the container NS", func() { _, err := creator.Setup(config) Expect(err).NotTo(HaveOccurred()) Expect(namespaceOpener.OpenPathCallCount()).To(Equal(1)) Expect(namespaceOpener.OpenPathArgsForCall(0)).To(Equal("/some/container/ns/path")) }) Context("when opening the container NS fails", func() { It("should return a meaningful error", func() { namespaceOpener.OpenPathReturns(nil, errors.New("turnip")) _, err := creator.Setup(config) Expect(err).To(MatchError("open container netns: turnip")) }) }) It("should return the info about the container", func() { container, err := creator.Setup(config) Expect(err).NotTo(HaveOccurred()) Expect(container).To(Equal(models.Container{