diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-01-30 20:59:35 -0800 |
|---|---|---|
| committer | Jeff Halter <jeff.d.halter@gmail.com> | 2022-01-30 20:59:35 -0800 |
| commit | d492c46d7e2087114d25f64823de9027592d5fc4 (patch) | |
| tree | cbe5440d759088fb1599e0582e211fb1c7f35b17 /hotline/file_store.go | |
| parent | 92a7e455a347e5be7fb69b6846b9f27ca698ae12 (diff) | |
Start moving file io into mockable interface
Diffstat (limited to 'hotline/file_store.go')
| -rw-r--r-- | hotline/file_store.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/hotline/file_store.go b/hotline/file_store.go index 81c1f05..b56d9a1 100644 --- a/hotline/file_store.go +++ b/hotline/file_store.go @@ -9,10 +9,9 @@ var FS FileStore type FileStore interface { Mkdir(name string, perm os.FileMode) error - Stat(name string) (os.FileInfo, error) - // TODO: implement - + Open(name string) (*os.File, error) + // TODO: implement these //Rename(oldpath string, newpath string) error //RemoveAll(path string) error } @@ -27,6 +26,10 @@ func (fs OSFileStore) Stat(name string) (os.FileInfo, error) { return os.Stat(name) } +func (fs OSFileStore) Open(name string) (*os.File, error) { + return os.Open(name) +} + type MockFileStore struct { mock.Mock } @@ -38,9 +41,14 @@ func (mfs MockFileStore) Mkdir(name string, perm os.FileMode) error { func (mfs MockFileStore) Stat(name string) (os.FileInfo, error) { args := mfs.Called(name) - if args.Get(0) == nil { + if args.Get(0) == nil { return nil, args.Error(1) } return args.Get(0).(os.FileInfo), args.Error(1) } + +func (mfs MockFileStore) Open(name string) (*os.File, error) { + args := mfs.Called(name) + return args.Get(0).(*os.File), args.Error(1) +} |