github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/daemon/config/config_windows_test.go (about) 1 // +build windows 2 3 package config // import "github.com/demonoid81/moby/daemon/config" 4 5 import ( 6 "io/ioutil" 7 "testing" 8 9 "github.com/demonoid81/moby/opts" 10 "github.com/spf13/pflag" 11 "gotest.tools/v3/assert" 12 is "gotest.tools/v3/assert/cmp" 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 assert.NilError(t, err) 50 51 assert.Check(t, cc.Debug) 52 assert.Check(t, cc.AutoRestart) 53 54 expectedLogConfig := LogConfig{ 55 Type: "syslog", 56 Config: map[string]string{"tag": "test_tag"}, 57 } 58 59 assert.Check(t, is.DeepEqual(expectedLogConfig, cc.LogConfig)) 60 }