Skip to content

Commit

Permalink
Add an action log to FakeMounter.
Browse files Browse the repository at this point in the history
# *** 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
  • Loading branch information
thockin committed Mar 13, 2015
1 parent 9929836 commit a061897
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion mount_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit a061897

Please sign in to comment.