diff options
Diffstat (limited to 'internal/vfs/memoryfs.go')
| -rw-r--r-- | internal/vfs/memoryfs.go | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/internal/vfs/memoryfs.go b/internal/vfs/memoryfs.go deleted file mode 100644 index 6250e39..0000000 --- a/internal/vfs/memoryfs.go +++ /dev/null @@ -1,34 +0,0 @@ -package vfs - -import ( - "fmt" - "strings" -) - -// VFS implementaion especially for unit testing. -type MemoryFS map[string][]byte - -func (fs MemoryFS) ReadFile(filePath string) ([]byte, error) { - if bytes, ok := fs[filePath]; ok { - return bytes, nil - } - return []byte{}, fmt.Errorf("no such file path: %s", filePath) -} - -func (fs MemoryFS) WriteFile(filePath string, bytes []byte) error { - fs[filePath] = bytes - return nil -} - -func (fs MemoryFS) FindFiles(dataDir, suffix string) ([]string, error) { - var filePaths []string - - for filePath := range fs { - if !strings.HasPrefix(filePath, dataDir) || !strings.HasSuffix(filePath, suffix) { - continue - } - filePaths = append(filePaths, filePath) - } - - return filePaths, nil -} |
