pkg/ns: test case for rejecting a non-ns nspath
This commit is contained in:
@ -17,6 +17,7 @@ package ns_test
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@ -169,6 +170,18 @@ var _ = Describe("Linux namespace operations", func() {
|
|||||||
Expect(netnsInode).NotTo(Equal(createdNetNSInode))
|
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() {
|
Describe("closing a network namespace", func() {
|
||||||
|
Reference in New Issue
Block a user