Add Contains wrapper for Namespaces type

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
Alexander Morozov 2014-12-23 11:13:45 -08:00
parent 2329014b6d
commit 5bb8146989
2 changed files with 6 additions and 2 deletions

View File

@ -57,6 +57,10 @@ func (n Namespaces) index(t NamespaceType) int {
return -1
}
func (n Namespaces) Contains(t NamespaceType) bool {
return n.index(t) != -1
}
// Config defines configuration options for executing a process inside a contained environment.
type Config struct {
// Mount specific options.

View File

@ -64,12 +64,12 @@ func TestConfigJsonFormat(t *testing.T) {
t.Fail()
}
if container.Namespaces.index(NEWNET) == -1 {
if !container.Namespaces.Contains(NEWNET) {
t.Log("namespaces should contain NEWNET")
t.Fail()
}
if container.Namespaces.index(NEWUSER) != -1 {
if container.Namespaces.Contains(NEWUSER) {
t.Log("namespaces should not contain NEWUSER")
t.Fail()
}