X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/85767504e4dc622c5ff469733e49c0cebcee57f1..5d7865ce3db756ab378728e478cb846d302a7c17:/hotline/file_store.go?ds=sidebyside diff --git a/hotline/file_store.go b/hotline/file_store.go index ed0ffa4..2ba9d7a 100644 --- a/hotline/file_store.go +++ b/hotline/file_store.go @@ -2,11 +2,10 @@ package hotline import ( "github.com/stretchr/testify/mock" + "io/fs" "os" ) -var FS FileStore - type FileStore interface { Mkdir(name string, perm os.FileMode) error Stat(name string) (os.FileInfo, error) @@ -14,6 +13,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 +45,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 +86,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) +}