diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2021-08-15 10:39:43 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2021-08-15 10:39:43 -0700 |
| commit | 00d1ef67636df59460bd4e060f6da4b0c9bcb24c (patch) | |
| tree | 23c0b75535ab187bd690e03e286b64395efeba2f /hotline/file_store.go | |
| parent | c5d9af5aa4d9fb20316be45ab1b775bcf61bcad5 (diff) | |
Tests and minor fixes
Diffstat (limited to 'hotline/file_store.go')
| -rw-r--r-- | hotline/file_store.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/hotline/file_store.go b/hotline/file_store.go new file mode 100644 index 0000000..81c1f05 --- /dev/null +++ b/hotline/file_store.go @@ -0,0 +1,46 @@ +package hotline + +import ( + "github.com/stretchr/testify/mock" + "os" +) + +var FS FileStore + +type FileStore interface { + Mkdir(name string, perm os.FileMode) error + + Stat(name string) (os.FileInfo, error) + // TODO: implement + + //Rename(oldpath string, newpath string) error + //RemoveAll(path string) error +} + +type OSFileStore struct{} + +func (fs OSFileStore) Mkdir(name string, perm os.FileMode) error { + return os.Mkdir(name, perm) +} + +func (fs OSFileStore) Stat(name string) (os.FileInfo, error) { + return os.Stat(name) +} + +type MockFileStore struct { + mock.Mock +} + +func (mfs MockFileStore) Mkdir(name string, perm os.FileMode) error { + args := mfs.Called(name, perm) + return args.Error(0) +} + +func (mfs MockFileStore) Stat(name string) (os.FileInfo, error) { + args := mfs.Called(name) + if args.Get(0) == nil { + return nil, args.Error(1) + + } + return args.Get(0).(os.FileInfo), args.Error(1) +} |