Documentation ¶
Overview ¶
Package filesnap simplifies reading and writing snapshots of files and their contents.
Here is an example of how to use this package during testing:
import ( "testing" "github.com/echocrow/fsnap/filesnap" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) type fsf = filesnap.Files func TestMyFilesConcat(t *testing.T) { dir := t.TempDir() // Source files snapshot. require.NoError(t, fsf{ "a_0.txt": []byte("prefix"), "a_1.txt": []byte("suffix"), }.Write(dir)) // Expected files snapshot. want := fsf{ "a.txt": []byte("prefix\nsuffix"), } err := MyFilesConcat(dir) assert.NoError(t, err) // Actual files snapshot. got, err := filesnap.Read(dir, -1) require.NoError(t, err) assert.Equal(t, want, got) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Files ¶
Files represents a snapshot of files in a directory and its subdirectories.
Keys represent the subpath of a file and values hold the contents of the respective file.
func Read ¶
Read scans a directory and returs its Files.
If n < 0, Read will scan all subdirectories.
If n >= 0, Read will descend at most n directory levels below directory dir.
Click to show internal directories.
Click to hide internal directories.