forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_settings_service.go
75 lines (59 loc) · 2.37 KB
/
fake_settings_service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package fakes
import (
boshsettings "github.com/cloudfoundry/bosh-agent/settings"
)
type FakeSettingsService struct {
PublicKey string
PublicKeyErr error
LoadSettingsError error
SettingsWereLoaded bool
GetPersistentDiskSettingsError error
GetAllPersistentDiskSettingsError error
PersistentDiskSettingsWereLoaded bool
RemovePersistentDiskSettingsError error
InvalidateSettingsError error
SettingsWereInvalidated bool
PersistentDiskSettings map[string]boshsettings.DiskSettings
Settings boshsettings.Settings
GetPersistentDiskSettingsCallCount int
RemovePersistentDiskSettingsCallCount int
RemovePersistentDiskSettingsLastArg string
SavePersistentDiskSettingsCallCount int
SavePersistentDiskSettingsErr error
SavePersistentDiskSettingsLastArg boshsettings.DiskSettings
}
func (service *FakeSettingsService) InvalidateSettings() error {
service.SettingsWereInvalidated = true
return service.InvalidateSettingsError
}
func (service *FakeSettingsService) PublicSSHKeyForUsername(_ string) (string, error) {
return service.PublicKey, service.PublicKeyErr
}
func (service *FakeSettingsService) LoadSettings() error {
service.SettingsWereLoaded = true
return service.LoadSettingsError
}
func (service FakeSettingsService) GetSettings() boshsettings.Settings {
return service.Settings
}
func (service *FakeSettingsService) GetPersistentDiskSettings(diskCID string) (boshsettings.DiskSettings, error) {
service.GetPersistentDiskSettingsCallCount++
service.PersistentDiskSettingsWereLoaded = true
return service.PersistentDiskSettings[diskCID], service.GetPersistentDiskSettingsError
}
func (service *FakeSettingsService) RemovePersistentDiskSettings(diskID string) error {
service.RemovePersistentDiskSettingsLastArg = diskID
service.RemovePersistentDiskSettingsCallCount++
return service.RemovePersistentDiskSettingsError
}
func (service *FakeSettingsService) SavePersistentDiskSettings(settings boshsettings.DiskSettings) error {
service.SavePersistentDiskSettingsCallCount++
service.SavePersistentDiskSettingsLastArg = settings
if service.SavePersistentDiskSettingsErr != nil {
return service.SavePersistentDiskSettingsErr
}
return nil
}
func (service *FakeSettingsService) GetAllPersistentDiskSettings() (map[string]boshsettings.DiskSettings, error) {
return service.PersistentDiskSettings, service.GetAllPersistentDiskSettingsError
}