mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
a1150245cc
Movified from686be57d0a
, and re-ran gofmt again to address for files not present in 20.10 and vice-versa. Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit686be57d0a
) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
85 lines
1.7 KiB
Go
85 lines
1.7 KiB
Go
//go:build !windows
|
|
// +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)
|
|
}
|
|
}
|
|
}
|