@@ -42,6 +42,40 @@ func TestFilesystemCanGetSliceOfFolderContents(t *testing.T) {
4242 }
4343}
4444
45+ func TestFilesystemCanGetSliceOfFolderContentsFromRelativeDir (t * testing.T ) {
46+ t .Chdir ("../testdata/project1/" )
47+
48+ filePaths , err := GetAllFilePaths ("." , nil )
49+ if err != nil {
50+ t .Fatalf ("expected filePaths, got error: %v" , err )
51+ }
52+ if filePaths == nil {
53+ t .Fatalf ("expected non-nil filePaths, got nil" )
54+ }
55+ // should only be 5 files
56+ // symbolic link in project1/symbolic-link should be ignored
57+ if len (filePaths ) != 5 {
58+ t .Fatalf ("expected %v, got %v" , 5 , len (filePaths ))
59+ }
60+
61+ // should be in alphabetical order, with files prefixed with '/'
62+ if filePaths [0 ] != "/emptyfile.testdata.txt" {
63+ t .Errorf ("expected %v, got %v" , "/emptyfile.testdata.txt" , filePaths [0 ])
64+ }
65+ if filePaths [1 ] != "/file1.testdata.txt" {
66+ t .Errorf ("expected %v, got %v" , "/file1.testdata.txt" , filePaths [1 ])
67+ }
68+ if filePaths [2 ] != "/file3.testdata.txt" {
69+ t .Errorf ("expected %v, got %v" , "/file3.testdata.txt" , filePaths [2 ])
70+ }
71+ if filePaths [3 ] != "/folder1/file4.testdata.txt" {
72+ t .Errorf ("expected %v, got %v" , "/folder1/file4.testdata.txt" , filePaths [3 ])
73+ }
74+ if filePaths [4 ] != "/lastfile.testdata.txt" {
75+ t .Errorf ("expected %v, got %v" , "/lastfile.testdata.txt" , filePaths [4 ])
76+ }
77+ }
78+
4579func TestFilesystemGetAllFilePathsFailsForNonExistentDirectory (t * testing.T ) {
4680 dirRoot := "./does/not/exist/"
4781
0 commit comments