Move unix specific logic into _unix.go
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
@@ -17,12 +17,10 @@ limitations under the License.
|
||||
package testing
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
containerdmount "github.com/containerd/containerd/mount"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
osInterface "github.com/containerd/cri/pkg/os"
|
||||
)
|
||||
@@ -42,7 +40,6 @@ type FakeOS struct {
|
||||
sync.Mutex
|
||||
MkdirAllFn func(string, os.FileMode) error
|
||||
RemoveAllFn func(string) error
|
||||
OpenFifoFn func(context.Context, string, int, os.FileMode) (io.ReadWriteCloser, error)
|
||||
StatFn func(string) (os.FileInfo, error)
|
||||
ResolveSymbolicLinkFn func(string) (string, error)
|
||||
FollowSymlinkInScopeFn func(string, string) (string, error)
|
||||
@@ -139,19 +136,6 @@ func (f *FakeOS) RemoveAll(path string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// OpenFifo is a fake call that invokes OpenFifoFn or just returns nil.
|
||||
func (f *FakeOS) OpenFifo(ctx context.Context, fn string, flag int, perm os.FileMode) (io.ReadWriteCloser, error) {
|
||||
f.appendCalls("OpenFifo", ctx, fn, flag, perm)
|
||||
if err := f.getError("OpenFifo"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if f.OpenFifoFn != nil {
|
||||
return f.OpenFifoFn(ctx, fn, flag, perm)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Stat is a fake call that invokes StatFn or just return nil.
|
||||
func (f *FakeOS) Stat(name string) (os.FileInfo, error) {
|
||||
f.appendCalls("Stat", name)
|
||||
|
||||
23
pkg/os/testing/fake_os_unix.go
Normal file
23
pkg/os/testing/fake_os_unix.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// +build !windows
|
||||
|
||||
/*
|
||||
Copyright The containerd Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package testing
|
||||
|
||||
import osInterface "github.com/containerd/cri/pkg/os"
|
||||
|
||||
var _ osInterface.UNIX = &FakeOS{}
|
||||
Reference in New Issue
Block a user