mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
03504cab65
1. replaced --net option for service UI with SERVICE.[NETWORK] format 2. Making using of the default network/driver backend support 3. NetworkName and NetworkType from the UI/API can be empty string and it will be replaced with DefaultNetwork and DefaultDriver As per the design goals, we wanted to keep libnetwork core free of handling defaults. Rather, the clients (docker & dnet) must handle the defaultness of these entities. Also, since there is no API to get these Default values from the backend, UI will not handle the default values either. Hence, this falls under the responsibility of the API layer to handle this specific case. Signed-off-by: Madhu Venugopal <madhu@docker.com>
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package config
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/docker/libnetwork/netlabel"
|
|
_ "github.com/docker/libnetwork/netutils"
|
|
)
|
|
|
|
func TestInvalidConfig(t *testing.T) {
|
|
_, err := ParseConfig("invalid.toml")
|
|
if err == nil {
|
|
t.Fatal("Invalid Configuration file must fail")
|
|
}
|
|
}
|
|
|
|
func TestConfig(t *testing.T) {
|
|
_, err := ParseConfig("libnetwork.toml")
|
|
if err != nil {
|
|
t.Fatal("Error parsing a valid configuration file :", err)
|
|
}
|
|
}
|
|
|
|
func TestOptionsLabels(t *testing.T) {
|
|
c := &Config{}
|
|
l := []string{
|
|
"com.docker.network.key1=value1",
|
|
"com.docker.storage.key1=value1",
|
|
"com.docker.network.driver.key1=value1",
|
|
"com.docker.network.driver.key2=value2",
|
|
}
|
|
f := OptionLabels(l)
|
|
f(c)
|
|
if len(c.Daemon.Labels) != 3 {
|
|
t.Fatalf("Expecting 3 labels, seen %d", len(c.Daemon.Labels))
|
|
}
|
|
for _, l := range c.Daemon.Labels {
|
|
if !strings.HasPrefix(l, netlabel.Prefix) {
|
|
t.Fatalf("config must accept only libnetwork labels. Not : %s", l)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestValidName(t *testing.T) {
|
|
if !IsValidName("test") {
|
|
t.Fatal("Name validation fails for a name that must be accepted")
|
|
}
|
|
if IsValidName("") {
|
|
t.Fatal("Name validation succeeds for a case when it is expected to fail")
|
|
}
|
|
if IsValidName("name.with.dots") {
|
|
t.Fatal("Name validation succeeds for a case when it is expected to fail")
|
|
}
|
|
}
|