package mfer import ( "testing" "github.com/davecgh/go-spew/spew" "github.com/spf13/afero" "github.com/stretchr/testify/assert" ) // Add those variables as well var ( existingFolder = "./testdata/a-folder-that-exists" ) var ( mf afero.Fs = afero.NewMemMapFs() af *afero.Afero = &afero.Afero{Fs: mf} ) func init() { // create test files and directories af.MkdirAll("/a/b/c", 0o755) af.MkdirAll("/.hidden", 0o755) afero.WriteFile(af, "/a/b/c/hello.txt", []byte("hello world\n\n\n\n"), 0o755) afero.WriteFile(af, "/a/b/c/hello2.txt", []byte("hello world\n\n\n\n"), 0o755) afero.WriteFile(af, "/.hidden/hello.txt", []byte("hello world\n"), 0o755) afero.WriteFile(af, "/.hidden/hello2.txt", []byte("hello world\n"), 0o755) } func TestPathHiddenFunc(t *testing.T) { assert.False(t, pathIsHidden("/a/b/c/hello.txt")) assert.True(t, pathIsHidden("/a/b/c/.hello.txt")) assert.True(t, pathIsHidden("/a/.b/c/hello.txt")) assert.True(t, pathIsHidden("/.a/b/c/hello.txt")) assert.False(t, pathIsHidden("./a/b/c/hello.txt")) } func TestManifestGenerationOne(t *testing.T) { m, err := NewFromFS(&ManifestScanOptions{ IgnoreDotfiles: true, }, mf) assert.Nil(t, err) assert.NotNil(t, m) assert.Equal(t, int64(2), m.GetFileCount()) assert.Equal(t, int64(30), m.GetTotalFileSize()) } func TestManifestGenerationTwo(t *testing.T) { m, err := NewFromFS(&ManifestScanOptions{ IgnoreDotfiles: false, }, mf) assert.Nil(t, err) assert.NotNil(t, m) spew.Dump(m) assert.Equal(t, int64(4), m.GetFileCount()) assert.Equal(t, int64(54), m.GetTotalFileSize()) err = m.generate() assert.Nil(t, err) }