pkg/ns: test IsNSFS()

This commit is contained in:
Stefan Junker 2016-05-24 22:30:01 +02:00
parent c43ccc703a
commit d6751cea24

View File

@ -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 {