diff options
| author | Paul Buetow <paul@buetow.org> | 2024-06-04 21:06:27 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-06-04 21:06:27 +0300 |
| commit | 76a98c26a3c8963a7eb5ab99cc479ba49e7730d8 (patch) | |
| tree | 8d0a52d268e2f6e5fe0e728085bc1116e29046fe /internal/vfs/memoryfs_test.go | |
| parent | 889cb5d997004adf0f37e3c14c5792defef0b6dc (diff) | |
more on testing
Diffstat (limited to 'internal/vfs/memoryfs_test.go')
| -rw-r--r-- | internal/vfs/memoryfs_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/vfs/memoryfs_test.go b/internal/vfs/memoryfs_test.go index 4d75500..f6a9cf1 100644 --- a/internal/vfs/memoryfs_test.go +++ b/internal/vfs/memoryfs_test.go @@ -36,6 +36,30 @@ func TestMemoryFS(t *testing.T) { } +func TestPassByValue(t *testing.T) { + t.Parallel() + fs := make(MemoryFS) + + writeFiles := map[string]string{ + "/data/dir/foo.json": "hello world", + "/data/dir/subdir/bar.json": "hello solar system", + "/data/dir/subdir/baz.json": "hello universe", + "/data/dir/subdir/bay.txt": "hello bar keeper", + } + + // Should work, as the underlying data type is a map. + func(fs MemoryFS) { + for path, content := range writeFiles { + bytes := []byte(content) + _ = fs.WriteFile(path, bytes) + } + }(fs) + + t.Run("files are there", func(t *testing.T) { + testFilesAreThere(t, fs, writeFiles) + }) +} + func testFilesAreThere(t *testing.T, fs MemoryFS, writeFiles map[string]string) { for path, content := range writeFiles { bytes, err := fs.ReadFile(path) |
