diff --git a/pkg/ns/ns_test.go b/pkg/ns/ns_test.go index d89e6936..82001ea0 100644 --- a/pkg/ns/ns_test.go +++ b/pkg/ns/ns_test.go @@ -211,6 +211,28 @@ var _ = Describe("Linux namespace operations", func() { }) }) }) + + Describe("IsNSFS", func() { + It("should detect a namespace", func() { + createdNetNS, err := ns.NewNS() + isNSFS, err := ns.IsNSFS(createdNetNS.Path()) + Expect(err).NotTo(HaveOccurred()) + Expect(isNSFS).To(Equal(true)) + }) + + It("should refuse other paths", func() { + tempFile, err := ioutil.TempFile("", "nstest") + Expect(err).NotTo(HaveOccurred()) + defer tempFile.Close() + + nspath := tempFile.Name() + defer os.Remove(nspath) + + isNSFS, err := ns.IsNSFS(nspath) + Expect(err).NotTo(HaveOccurred()) + Expect(isNSFS).To(Equal(false)) + }) + }) }) func allNetNSInCurrentProcess() []string {