mocked_config_test.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // Copyright (C) 2016 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package api
  7. import (
  8. "github.com/syncthing/syncthing/lib/config"
  9. "github.com/syncthing/syncthing/lib/protocol"
  10. "github.com/syncthing/syncthing/lib/util"
  11. )
  12. type mockedConfig struct {
  13. gui config.GUIConfiguration
  14. }
  15. func (c *mockedConfig) GUI() config.GUIConfiguration {
  16. return c.gui
  17. }
  18. func (c *mockedConfig) ListenAddresses() []string {
  19. return nil
  20. }
  21. func (c *mockedConfig) LDAP() config.LDAPConfiguration {
  22. return config.LDAPConfiguration{}
  23. }
  24. func (c *mockedConfig) RawCopy() config.Configuration {
  25. cfg := config.Configuration{}
  26. util.SetDefaults(&cfg.Options)
  27. return cfg
  28. }
  29. func (c *mockedConfig) Options() config.OptionsConfiguration {
  30. return config.OptionsConfiguration{}
  31. }
  32. func (c *mockedConfig) Modify(config.ModifyFunction) (config.Waiter, error) {
  33. return noopWaiter{}, nil
  34. }
  35. func (c *mockedConfig) Subscribe(cm config.Committer) config.Configuration {
  36. return config.Configuration{}
  37. }
  38. func (c *mockedConfig) Unsubscribe(cm config.Committer) {}
  39. func (c *mockedConfig) Folders() map[string]config.FolderConfiguration {
  40. return nil
  41. }
  42. func (c *mockedConfig) Devices() map[protocol.DeviceID]config.DeviceConfiguration {
  43. return nil
  44. }
  45. func (c *mockedConfig) DeviceList() []config.DeviceConfiguration {
  46. return nil
  47. }
  48. func (c *mockedConfig) Save() error {
  49. return nil
  50. }
  51. func (c *mockedConfig) RequiresRestart() bool {
  52. return false
  53. }
  54. func (c *mockedConfig) AddOrUpdatePendingDevice(device protocol.DeviceID, name, address string) {}
  55. func (c *mockedConfig) AddOrUpdatePendingFolder(id, label string, device protocol.DeviceID) {}
  56. func (c *mockedConfig) ConfigPath() string {
  57. return ""
  58. }
  59. func (c *mockedConfig) Folder(id string) (config.FolderConfiguration, bool) {
  60. return config.FolderConfiguration{}, false
  61. }
  62. func (c *mockedConfig) FolderList() []config.FolderConfiguration {
  63. return nil
  64. }
  65. func (c *mockedConfig) RemoveFolder(id string) (config.Waiter, error) {
  66. return noopWaiter{}, nil
  67. }
  68. func (c *mockedConfig) FolderPasswords(device protocol.DeviceID) map[string]string {
  69. return nil
  70. }
  71. func (c *mockedConfig) Device(id protocol.DeviceID) (config.DeviceConfiguration, bool) {
  72. return config.DeviceConfiguration{}, false
  73. }
  74. func (c *mockedConfig) RemoveDevice(id protocol.DeviceID) (config.Waiter, error) {
  75. return noopWaiter{}, nil
  76. }
  77. func (c *mockedConfig) IgnoredDevice(id protocol.DeviceID) bool {
  78. return false
  79. }
  80. func (c *mockedConfig) IgnoredDevices() []config.ObservedDevice {
  81. return nil
  82. }
  83. func (c *mockedConfig) IgnoredFolder(device protocol.DeviceID, folder string) bool {
  84. return false
  85. }
  86. func (c *mockedConfig) DefaultFolder() config.FolderConfiguration {
  87. return config.FolderConfiguration{}
  88. }
  89. func (c *mockedConfig) SetDefaultFolder(config.FolderConfiguration) (config.Waiter, error) {
  90. return noopWaiter{}, nil
  91. }
  92. func (c *mockedConfig) DefaultDevice() config.DeviceConfiguration {
  93. return config.DeviceConfiguration{}
  94. }
  95. func (c *mockedConfig) SetDefaultDevice(config.DeviceConfiguration) (config.Waiter, error) {
  96. return noopWaiter{}, nil
  97. }
  98. func (c *mockedConfig) GlobalDiscoveryServers() []string {
  99. return nil
  100. }
  101. func (c *mockedConfig) StunServers() []string {
  102. return nil
  103. }
  104. func (c *mockedConfig) MyID() protocol.DeviceID {
  105. return protocol.DeviceID{}
  106. }
  107. type noopWaiter struct{}
  108. func (noopWaiter) Wait() {}