Add an action log to FakeMounter.

# *** ERROR: *** docs are out of sync between cli and markdown
# run hack/run-gendocs.sh > docs/kubectl.md to regenerate

#
# Your commit will be aborted unless you regenerate docs.
    COMMIT_BLOCKED_ON_GENDOCS
This commit is contained in:
Tim Hockin
2015-03-07 12:33:26 -08:00
parent 22f306299b
commit 50c96789e7
2 changed files with 21 additions and 2 deletions

View File

@@ -16,16 +16,35 @@ limitations under the License.
package mount
// FakeMounter implements mount.Interface.
// FakeMounter implements mount.Interface for tests.
type FakeMounter struct {
MountPoints []MountPoint
Log []FakeAction
}
// Values for FakeAction.Action
const FakeActionMount = "mount"
const FakeActionUnmount = "unmount"
// FakeAction objects are logged every time a fake mount or unmount is called.
type FakeAction struct {
Action string // "mount" or "unmount"
Target string // applies to both mount and unmount actions
Source string // applies only to "mount" actions
FSType string // applies only to "mount" actions
}
func (f *FakeMounter) ResetLog() {
f.Log = []FakeAction{}
}
func (f *FakeMounter) Mount(source string, target string, fstype string, flags uintptr, data string) error {
f.Log = append(f.Log, FakeAction{Action: FakeActionMount, Target: target, Source: source, FSType: fstype})
return nil
}
func (f *FakeMounter) Unmount(target string, flags int) error {
f.Log = append(f.Log, FakeAction{Action: FakeActionUnmount, Target: target})
return nil
}

View File

@@ -94,7 +94,7 @@ func slicesEqual(a, b []string) bool {
func TestGetMountRefs(t *testing.T) {
fm := &FakeMounter{
[]MountPoint{
MountPoints: []MountPoint{
{Device: "/dev/sdb", Path: "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd"},
{Device: "/dev/sdb", Path: "/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~gce-pd/gce-pd-in-pod"},
{Device: "/dev/sdc", Path: "/var/lib/kubelet/plugins/kubernetes.io/gce-pd/mounts/gce-pd2"},