@@ -21,6 +21,7 @@ import (
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
containerdmount "github.com/containerd/containerd/mount"
|
||||
"github.com/docker/docker/pkg/mount"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
@@ -50,6 +51,8 @@ type FakeOS struct {
|
||||
MountFn func(source string, target string, fstype string, flags uintptr, data string) error
|
||||
UnmountFn func(target string, flags int) error
|
||||
GetMountsFn func() ([]*mount.Info, error)
|
||||
LookupMountFn func(path string) (containerdmount.Info, error)
|
||||
DeviceUUIDFn func(device string) (string, error)
|
||||
calls []CalledDetail
|
||||
errors map[string]error
|
||||
}
|
||||
@@ -240,3 +243,29 @@ func (f *FakeOS) GetMounts() ([]*mount.Info, error) {
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// LookupMount is a fake call that invokes LookupMountFn or just return nil.
|
||||
func (f *FakeOS) LookupMount(path string) (containerdmount.Info, error) {
|
||||
f.appendCalls("LookupMount", path)
|
||||
if err := f.getError("LookupMount"); err != nil {
|
||||
return containerdmount.Info{}, err
|
||||
}
|
||||
|
||||
if f.LookupMountFn != nil {
|
||||
return f.LookupMountFn(path)
|
||||
}
|
||||
return containerdmount.Info{}, nil
|
||||
}
|
||||
|
||||
// DeviceUUID is a fake call that invodes DeviceUUIDFn or just return nil.
|
||||
func (f *FakeOS) DeviceUUID(device string) (string, error) {
|
||||
f.appendCalls("DeviceUUID", device)
|
||||
if err := f.getError("DeviceUUID"); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if f.DeviceUUIDFn != nil {
|
||||
return f.DeviceUUIDFn(device)
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user