mocked_config_test.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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) SetLDAP(config.LDAPConfiguration) (config.Waiter, error) {
  25. return noopWaiter{}, nil
  26. }
  27. func (c *mockedConfig) RawCopy() config.Configuration {
  28. cfg := config.Configuration{}
  29. util.SetDefaults(&cfg.Options)
  30. return cfg
  31. }
  32. func (c *mockedConfig) Options() config.OptionsConfiguration {
  33. return config.OptionsConfiguration{}
  34. }
  35. func (c *mockedConfig) Replace(cfg config.Configuration) (config.Waiter, error) {
  36. return noopWaiter{}, nil
  37. }
  38. func (c *mockedConfig) Subscribe(cm config.Committer) {}
  39. func (c *mockedConfig) Unsubscribe(cm config.Committer) {}
  40. func (c *mockedConfig) Folders() map[string]config.FolderConfiguration {
  41. return nil
  42. }
  43. func (c *mockedConfig) Devices() map[protocol.DeviceID]config.DeviceConfiguration {
  44. return nil
  45. }
  46. func (c *mockedConfig) DeviceList() []config.DeviceConfiguration {
  47. return nil
  48. }
  49. func (c *mockedConfig) SetDevice(config.DeviceConfiguration) (config.Waiter, error) {
  50. return noopWaiter{}, nil
  51. }
  52. func (c *mockedConfig) SetDevices([]config.DeviceConfiguration) (config.Waiter, error) {
  53. return noopWaiter{}, nil
  54. }
  55. func (c *mockedConfig) Save() error {
  56. return nil
  57. }
  58. func (c *mockedConfig) RequiresRestart() bool {
  59. return false
  60. }
  61. func (c *mockedConfig) AddOrUpdatePendingDevice(device protocol.DeviceID, name, address string) {}
  62. func (c *mockedConfig) AddOrUpdatePendingFolder(id, label string, device protocol.DeviceID) {}
  63. func (c *mockedConfig) ConfigPath() string {
  64. return ""
  65. }
  66. func (c *mockedConfig) SetGUI(gui config.GUIConfiguration) (config.Waiter, error) {
  67. return noopWaiter{}, nil
  68. }
  69. func (c *mockedConfig) SetOptions(opts config.OptionsConfiguration) (config.Waiter, error) {
  70. return noopWaiter{}, nil
  71. }
  72. func (c *mockedConfig) Folder(id string) (config.FolderConfiguration, bool) {
  73. return config.FolderConfiguration{}, false
  74. }
  75. func (c *mockedConfig) FolderList() []config.FolderConfiguration {
  76. return nil
  77. }
  78. func (c *mockedConfig) SetFolder(fld config.FolderConfiguration) (config.Waiter, error) {
  79. return noopWaiter{}, nil
  80. }
  81. func (c *mockedConfig) SetFolders(folders []config.FolderConfiguration) (config.Waiter, error) {
  82. return noopWaiter{}, nil
  83. }
  84. func (c *mockedConfig) RemoveFolder(id string) (config.Waiter, error) {
  85. return noopWaiter{}, nil
  86. }
  87. func (c *mockedConfig) Device(id protocol.DeviceID) (config.DeviceConfiguration, bool) {
  88. return config.DeviceConfiguration{}, false
  89. }
  90. func (c *mockedConfig) RemoveDevice(id protocol.DeviceID) (config.Waiter, error) {
  91. return noopWaiter{}, nil
  92. }
  93. func (c *mockedConfig) IgnoredDevice(id protocol.DeviceID) bool {
  94. return false
  95. }
  96. func (c *mockedConfig) IgnoredFolder(device protocol.DeviceID, folder string) bool {
  97. return false
  98. }
  99. func (c *mockedConfig) GlobalDiscoveryServers() []string {
  100. return nil
  101. }
  102. func (c *mockedConfig) StunServers() []string {
  103. return nil
  104. }
  105. type noopWaiter struct{}
  106. func (noopWaiter) Wait() {}