1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #11686 from willhf/9340_test

Add test for net=container and links
This commit is contained in:
Arnaud Porterie 2015-04-06 13:21:01 -07:00
commit 8a50746b5d
2 changed files with 8 additions and 2 deletions

View file

@ -125,7 +125,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
return nil, nil, cmd, ErrConflictHostNetworkAndLinks
}
if *flNetMode == "container" && flLinks.Len() > 0 {
if strings.HasPrefix(*flNetMode, "container") && flLinks.Len() > 0 {
return nil, nil, cmd, ErrConflictContainerNetworkAndLinks
}
@ -133,7 +133,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
return nil, nil, cmd, ErrConflictHostNetworkAndDns
}
if *flNetMode == "container" && flDns.Len() > 0 {
if strings.HasPrefix(*flNetMode, "container") && flDns.Len() > 0 {
return nil, nil, cmd, ErrConflictContainerNetworkAndDns
}

View file

@ -57,3 +57,9 @@ func TestNetHostname(t *testing.T) {
t.Fatalf("Expected error ErrConflictNetworkHostname, got: %s", err)
}
}
func TestConflictContainerNetworkAndLinks(t *testing.T) {
if _, _, _, err := parseRun([]string{"--net=container:other", "--link=zip:zap", "img", "cmd"}); err != ErrConflictContainerNetworkAndLinks {
t.Fatalf("Expected error ErrConflictContainerNetworkAndLinks, got: %s", err)
}
}