1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/daemon/config/config_common_unix_test.go
Daniel Nephin 4f0d95fa6e Add canonical import comment
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-05 16:51:57 -05:00

84 lines
1.7 KiB
Go

// +build !windows
package config // import "github.com/docker/docker/daemon/config"
import (
"testing"
"github.com/docker/docker/api/types"
)
func TestCommonUnixValidateConfigurationErrors(t *testing.T) {
testCases := []struct {
config *Config
}{
// Can't override the stock runtime
{
config: &Config{
CommonUnixConfig: CommonUnixConfig{
Runtimes: map[string]types.Runtime{
StockRuntimeName: {},
},
},
},
},
// Default runtime should be present in runtimes
{
config: &Config{
CommonUnixConfig: CommonUnixConfig{
Runtimes: map[string]types.Runtime{
"foo": {},
},
DefaultRuntime: "bar",
},
},
},
}
for _, tc := range testCases {
err := Validate(tc.config)
if err == nil {
t.Fatalf("expected error, got nil for config %v", tc.config)
}
}
}
func TestCommonUnixGetInitPath(t *testing.T) {
testCases := []struct {
config *Config
expectedInitPath string
}{
{
config: &Config{
InitPath: "some-init-path",
},
expectedInitPath: "some-init-path",
},
{
config: &Config{
CommonUnixConfig: CommonUnixConfig{
DefaultInitBinary: "foo-init-bin",
},
},
expectedInitPath: "foo-init-bin",
},
{
config: &Config{
InitPath: "init-path-A",
CommonUnixConfig: CommonUnixConfig{
DefaultInitBinary: "init-path-B",
},
},
expectedInitPath: "init-path-A",
},
{
config: &Config{},
expectedInitPath: "docker-init",
},
}
for _, tc := range testCases {
initPath := tc.config.GetInitPath()
if initPath != tc.expectedInitPath {
t.Fatalf("expected initPath to be %v, got %v", tc.expectedInitPath, initPath)
}
}
}