From: Stefan Junker Date: Tue, 24 May 2016 18:48:12 +0000 (+0200) Subject: pkg/ns: add tests cases for Close()'d NS X-Git-Url: https://git.halfball.org/?a=commitdiff_plain;h=2de97b7e98c0069099a05a29f09d5b4d9db9cc71;p=plugins.git pkg/ns: add tests cases for Close()'d NS --- diff --git a/pkg/ns/ns_test.go b/pkg/ns/ns_test.go index 836025e..de0f385 100644 --- a/pkg/ns/ns_test.go +++ b/pkg/ns/ns_test.go @@ -170,6 +170,33 @@ var _ = Describe("Linux namespace operations", func() { } }) }) + + Describe("closing a network namespace", func() { + It("should prevent further operations", func() { + createdNetNS, err := ns.NewNS() + Expect(err).NotTo(HaveOccurred()) + + err = createdNetNS.Close() + Expect(err).NotTo(HaveOccurred()) + + err = createdNetNS.Do(func(ns.NetNS) error { return nil }) + Expect(err).To(HaveOccurred()) + + err = createdNetNS.Set() + Expect(err).To(HaveOccurred()) + }) + + It("should only work once", func() { + createdNetNS, err := ns.NewNS() + Expect(err).NotTo(HaveOccurred()) + + err = createdNetNS.Close() + Expect(err).NotTo(HaveOccurred()) + + err = createdNetNS.Close() + Expect(err).To(HaveOccurred()) + }) + }) }) })