]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/file_store.go
Refactor listener setup
[rbdr/mobius] / hotline / file_store.go
index ed0ffa492448cc05b5fec976005af9aee1936870..ba86c6a3b434f4dc5195033be2eecec62b965632 100644 (file)
@@ -2,6 +2,7 @@ package hotline
 
 import (
        "github.com/stretchr/testify/mock"
 
 import (
        "github.com/stretchr/testify/mock"
+       "io/fs"
        "os"
 )
 
        "os"
 )
 
@@ -14,6 +15,7 @@ type FileStore interface {
        Symlink(oldname, newname string) error
        Remove(name string) error
        Create(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
        // 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)
 }
 
        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
 }
 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)
 }
        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)
+}