Add Contains wrapper for Namespaces type
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
2329014b6d
commit
5bb8146989
|
@ -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.
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue