forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_mounter.go
95 lines (78 loc) · 2.93 KB
/
fake_mounter.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package fakes
type FakeMounter struct {
MountCalled bool
MountPartitionPaths []string
MountMountPoints []string
MountMountOptions [][]string
MountErr error
RemountInPlaceCalled bool
RemountInPlaceMountPoints []string
RemountInPlaceMountOptions [][]string
RemountInPlaceErr error
RemountAsReadonlyCalled bool
RemountAsReadonlyPath string
RemountAsReadonlyErr error
RemountFromMountPoint string
RemountToMountPoint string
RemountMountOptions []string
RemountErr error
SwapOnPartitionPaths []string
SwapOnErr error
UnmountPartitionPathOrMountPoint string
UnmountDidUnmount bool
UnmountErr error
IsMountPointPath string
IsMountPointPartitionPath string
IsMountPointResult bool
IsMountPointErr error
IsMountedResult bool
IsMountedErr error
IsMountedStub func(string) (bool, error)
isMountedArgs []string
}
func (m *FakeMounter) Mount(partitionPath, mountPoint string, mountOptions ...string) error {
m.MountCalled = true
m.MountPartitionPaths = append(m.MountPartitionPaths, partitionPath)
m.MountMountPoints = append(m.MountMountPoints, mountPoint)
m.MountMountOptions = append(m.MountMountOptions, mountOptions)
return m.MountErr
}
func (m *FakeMounter) RemountAsReadonly(mountPoint string) (err error) {
m.RemountAsReadonlyCalled = true
m.RemountAsReadonlyPath = mountPoint
return m.RemountAsReadonlyErr
}
func (m *FakeMounter) Remount(fromMountPoint, toMountPoint string, mountOptions ...string) (err error) {
m.RemountFromMountPoint = fromMountPoint
m.RemountToMountPoint = toMountPoint
m.RemountMountOptions = mountOptions
return m.RemountErr
}
func (m *FakeMounter) SwapOn(partitionPath string) (err error) {
m.SwapOnPartitionPaths = append(m.SwapOnPartitionPaths, partitionPath)
return m.SwapOnErr
}
func (m *FakeMounter) Unmount(partitionPathOrMountPoint string) (didUnmount bool, err error) {
m.UnmountPartitionPathOrMountPoint = partitionPathOrMountPoint
return m.UnmountDidUnmount, m.UnmountErr
}
func (m *FakeMounter) IsMountPoint(path string) (partitionPath string, result bool, err error) {
m.IsMountPointPath = path
return m.IsMountPointPartitionPath, m.IsMountPointResult, m.IsMountPointErr
}
func (m *FakeMounter) IsMounted(devicePathOrMountPoint string) (bool, error) {
m.isMountedArgs = append(m.isMountedArgs, devicePathOrMountPoint)
if m.IsMountedStub != nil {
return m.IsMountedStub(devicePathOrMountPoint)
}
return m.IsMountedResult, m.IsMountedErr
}
func (m *FakeMounter) IsMountedArgsForCall(callNumber int) string {
return m.isMountedArgs[callNumber]
}
func (m *FakeMounter) RemountInPlace(mountPoint string, mountOptions ...string) error {
m.RemountInPlaceCalled = true
m.RemountInPlaceMountPoints = append(m.RemountInPlaceMountPoints, mountPoint)
m.RemountInPlaceMountOptions = append(m.RemountInPlaceMountOptions, mountOptions)
return m.RemountInPlaceErr
}