github.com/skanehira/moby@v17.12.1-ce-rc2+incompatible/daemon/config/config_windows_test.go (about) 1 // +build windows 2 3 package config 4 5 import ( 6 "io/ioutil" 7 "testing" 8 9 "github.com/docker/docker/opts" 10 "github.com/spf13/pflag" 11 "github.com/stretchr/testify/assert" 12 "github.com/stretchr/testify/require" 13 ) 14 15 func TestDaemonConfigurationMerge(t *testing.T) { 16 f, err := ioutil.TempFile("", "docker-config-") 17 if err != nil { 18 t.Fatal(err) 19 } 20 21 configFile := f.Name() 22 23 f.Write([]byte(` 24 { 25 "debug": true, 26 "log-opts": { 27 "tag": "test_tag" 28 } 29 }`)) 30 31 f.Close() 32 33 c := &Config{ 34 CommonConfig: CommonConfig{ 35 AutoRestart: true, 36 LogConfig: LogConfig{ 37 Type: "syslog", 38 Config: map[string]string{"tag": "test"}, 39 }, 40 }, 41 } 42 43 flags := pflag.NewFlagSet("test", pflag.ContinueOnError) 44 var debug bool 45 flags.BoolVarP(&debug, "debug", "D", false, "") 46 flags.Var(opts.NewNamedMapOpts("log-opts", nil, nil), "log-opt", "") 47 48 cc, err := MergeDaemonConfigurations(c, flags, configFile) 49 require.NoError(t, err) 50 51 assert.True(t, cc.Debug) 52 assert.True(t, cc.AutoRestart) 53 54 expectedLogConfig := LogConfig{ 55 Type: "syslog", 56 Config: map[string]string{"tag": "test_tag"}, 57 } 58 59 assert.Equal(t, expectedLogConfig, cc.LogConfig) 60 }