config_windows_test.go 1.1 KB

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