From c43ccc703a7cf02b408af95d29a7a95ffefc62f1 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Tue, 24 May 2016 22:21:57 +0200 Subject: [PATCH] pkg/ns: test case for rejecting a non-ns nspath --- pkg/ns/ns_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/ns/ns_test.go b/pkg/ns/ns_test.go index de0f3853..d89e6936 100644 --- a/pkg/ns/ns_test.go +++ b/pkg/ns/ns_test.go @@ -17,6 +17,7 @@ package ns_test import ( "errors" "fmt" + "io/ioutil" "os" "path/filepath" @@ -169,6 +170,18 @@ var _ = Describe("Linux namespace operations", func() { Expect(netnsInode).NotTo(Equal(createdNetNSInode)) } }) + + It("fails when the path is not a namespace", func() { + tempFile, err := ioutil.TempFile("", "nstest") + Expect(err).NotTo(HaveOccurred()) + defer tempFile.Close() + + nspath := tempFile.Name() + defer os.Remove(nspath) + + _, err = ns.GetNS(nspath) + Expect(err).To(MatchError(fmt.Sprintf("%v is not of type NSFS", nspath))) + }) }) Describe("closing a network namespace", func() {