github.com/openshift/moby-moby@v1.13.2-0.20170601211448-f5ec1e2936dc/daemon/config_windows_test.go (about)

     1  // +build windows
     2  
     3  package daemon
     4  
     5  import (
     6  	"io/ioutil"
     7  	"testing"
     8  )
     9  
    10  func TestDaemonConfigurationMerge(t *testing.T) {
    11  	f, err := ioutil.TempFile("", "docker-config-")
    12  	if err != nil {
    13  		t.Fatal(err)
    14  	}
    15  
    16  	configFile := f.Name()
    17  
    18  	f.Write([]byte(`
    19  		{
    20  			"debug": true,
    21  			"log-opts": {
    22  				"tag": "test_tag"
    23  			}
    24  		}`))
    25  
    26  	f.Close()
    27  
    28  	c := &Config{
    29  		CommonConfig: CommonConfig{
    30  			AutoRestart: true,
    31  			LogConfig: LogConfig{
    32  				Type:   "syslog",
    33  				Config: map[string]string{"tag": "test"},
    34  			},
    35  		},
    36  	}
    37  
    38  	cc, err := MergeDaemonConfigurations(c, nil, configFile)
    39  	if err != nil {
    40  		t.Fatal(err)
    41  	}
    42  	if !cc.Debug {
    43  		t.Fatalf("expected %v, got %v\n", true, cc.Debug)
    44  	}
    45  	if !cc.AutoRestart {
    46  		t.Fatalf("expected %v, got %v\n", true, cc.AutoRestart)
    47  	}
    48  	if cc.LogConfig.Type != "syslog" {
    49  		t.Fatalf("expected syslog config, got %q\n", cc.LogConfig)
    50  	}
    51  
    52  	if configValue, OK := cc.LogConfig.Config["tag"]; !OK {
    53  		t.Fatal("expected syslog config attributes, got nil\n")
    54  	} else {
    55  		if configValue != "test_tag" {
    56  			t.Fatalf("expected syslog config attributes 'tag=test_tag', got 'tag=%s'\n", configValue)
    57  		}
    58  	}
    59  }