expand FileSet tests with cases root != worktreeRoot

This commit is contained in:
Denis Bilenko 2024-12-03 09:52:53 +01:00
parent e7a49a249d
commit c4c7a872a9
1 changed files with 14 additions and 4 deletions

View File

@ -12,8 +12,8 @@ import (
"github.com/stretchr/testify/require"
)
func testFileSetAll(t *testing.T, root string) {
fileSet, err := NewFileSetAtRoot(vfs.MustNew(root))
func testFileSetAll(t *testing.T, worktreeRoot, root string) {
fileSet, err := NewFileSet(vfs.MustNew(worktreeRoot), vfs.MustNew(root))
require.NoError(t, err)
files, err := fileSet.Files()
require.NoError(t, err)
@ -24,11 +24,21 @@ func testFileSetAll(t *testing.T, root string) {
}
func TestFileSetListAllInRepo(t *testing.T) {
testFileSetAll(t, "./testdata")
testFileSetAll(t, "./testdata", "./testdata")
}
func TestFileSetListAllInRepoDifferentRoot(t *testing.T) {
testFileSetAll(t, ".", "./testdata")
}
func TestFileSetListAllInTempDir(t *testing.T) {
testFileSetAll(t, copyTestdata(t, "./testdata"))
dir := copyTestdata(t, "./testdata")
testFileSetAll(t, dir, dir)
}
func TestFileSetListAllInTempDirDifferentRoot(t *testing.T) {
dir := copyTestdata(t, "./testdata")
testFileSetAll(t, filepath.Dir(dir), dir)
}
func TestFileSetNonCleanRoot(t *testing.T) {