mocked_config_test.go 3.2 KB

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