X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/85767504e4dc622c5ff469733e49c0cebcee57f1..aeec10158441af3cef925ca55e531a4d5517d5ec:/hotline/file_store.go diff --git a/hotline/file_store.go b/hotline/file_store.go index ed0ffa4..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" ) @@ -14,6 +15,7 @@ type FileStore interface { 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 @@ -45,6 +47,10 @@ 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 } @@ -82,3 +88,8 @@ 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) +}