From ab2f8d70ee67661197fc5ec43b00d44188b643bb Mon Sep 17 00:00:00 2001 From: Yusuf Kanchwala Date: Thu, 13 Aug 2020 15:17:42 +0530 Subject: [PATCH] fix TestFindAllDirectories unit tests --- pkg/utils/path_test.go | 15 ++++++++------- pkg/utils/testdata/emptydir/somefile.txt | 1 + pkg/utils/testdata/testdir1/somefile.txt | 1 + pkg/utils/testdata/testdir2/somefile.txt | 1 + 4 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 pkg/utils/testdata/emptydir/somefile.txt create mode 100644 pkg/utils/testdata/testdir1/somefile.txt create mode 100644 pkg/utils/testdata/testdir2/somefile.txt diff --git a/pkg/utils/path_test.go b/pkg/utils/path_test.go index 5b47d4076..2344c50e7 100644 --- a/pkg/utils/path_test.go +++ b/pkg/utils/path_test.go @@ -17,7 +17,6 @@ package utils import ( - "fmt" "os" "reflect" "testing" @@ -90,12 +89,6 @@ func TestFindAllDirectories(t *testing.T) { want: []string{"./testdata/emptydir"}, wantErr: nil, }, - { - name: "invalid dir", - basePath: "./testdata/nothere", - want: []string{}, - wantErr: fmt.Errorf("lstat ./testdata/nothere: no such file or directory"), - }, } for _, tt := range table { @@ -109,4 +102,12 @@ func TestFindAllDirectories(t *testing.T) { } }) } + + t.Run("invalid dir", func(t *testing.T) { + basePath := "./testdata/nothere" + _, gotErr := FindAllDirectories(basePath) + if gotErr == nil { + t.Errorf("got no error; error expected") + } + }) } diff --git a/pkg/utils/testdata/emptydir/somefile.txt b/pkg/utils/testdata/emptydir/somefile.txt new file mode 100644 index 000000000..ebf038b91 --- /dev/null +++ b/pkg/utils/testdata/emptydir/somefile.txt @@ -0,0 +1 @@ +somefile diff --git a/pkg/utils/testdata/testdir1/somefile.txt b/pkg/utils/testdata/testdir1/somefile.txt new file mode 100644 index 000000000..ebf038b91 --- /dev/null +++ b/pkg/utils/testdata/testdir1/somefile.txt @@ -0,0 +1 @@ +somefile diff --git a/pkg/utils/testdata/testdir2/somefile.txt b/pkg/utils/testdata/testdir2/somefile.txt new file mode 100644 index 000000000..ebf038b91 --- /dev/null +++ b/pkg/utils/testdata/testdir2/somefile.txt @@ -0,0 +1 @@ +somefile