X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/003a743e6767b3041c3a8321566c3586d73b399a..e130e0a2142f123d9d6f9351d0758289f010a1bb:/hotline/file_store.go?ds=sidebyside diff --git a/hotline/file_store.go b/hotline/file_store.go index e9d083f..ba86c6a 100644 --- a/hotline/file_store.go +++ b/hotline/file_store.go @@ -2,6 +2,7 @@ package hotline import ( "github.com/stretchr/testify/mock" + "io/fs" "os" ) @@ -13,6 +14,8 @@ type FileStore interface { Open(name string) (*os.File, error) Symlink(oldname, newname string) error Remove(name string) error + Create(name string) (*os.File, error) + WriteFile(name string, data []byte, perm fs.FileMode) error // TODO: implement these // Rename(oldpath string, newpath string) error // RemoveAll(path string) error @@ -40,6 +43,14 @@ func (fs *OSFileStore) Remove(name string) error { return os.Remove(name) } +func (fs *OSFileStore) Create(name string) (*os.File, error) { + return os.Create(name) +} + +func (fs *OSFileStore) WriteFile(name string, data []byte, perm fs.FileMode) error { + return os.WriteFile(name, data, perm) +} + type MockFileStore struct { mock.Mock } @@ -72,3 +83,13 @@ func (mfs *MockFileStore) Remove(name string) error { args := mfs.Called(name) return args.Error(0) } + +func (mfs *MockFileStore) Create(name string) (*os.File, error) { + args := mfs.Called(name) + return args.Get(0).(*os.File), args.Error(1) +} + +func (mfs *MockFileStore) WriteFile(name string, data []byte, perm fs.FileMode) error { + args := mfs.Called(name, data, perm) + return args.Error(0) +}