Fix hostname env.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2018-09-10 10:52:13 -07:00
parent cfdf872493
commit f08a90ff64
5 changed files with 75 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ type FakeOS struct {
MountFn func(source string, target string, fstype string, flags uintptr, data string) error
UnmountFn func(target string) error
LookupMountFn func(path string) (containerdmount.Info, error)
HostnameFn func() (string, error)
calls []CalledDetail
errors map[string]error
}
@@ -254,3 +255,16 @@ func (f *FakeOS) LookupMount(path string) (containerdmount.Info, error) {
}
return containerdmount.Info{}, nil
}
// Hostname is a fake call that invokes HostnameFn or just return nil.
func (f *FakeOS) Hostname() (string, error) {
f.appendCalls("Hostname")
if err := f.getError("Hostname"); err != nil {
return "", err
}
if f.HostnameFn != nil {
return f.HostnameFn()
}
return "", nil
}