diff options
| author | RanXom <saiyedshizain@gmail.com> | 2026-07-13 01:40:30 +0530 |
|---|---|---|
| committer | RanXom <saiyedshizain@gmail.com> | 2026-07-13 01:40:30 +0530 |
| commit | 8232962d857ca88c442e17a7423950d24a3514ee (patch) | |
| tree | 792976c686356ea725cfef7154a928fa75f0eb0d /internal/scanner | |
| parent | 0bf9d862f53ac8df409f71acea651fc5ef991698 (diff) | |
| download | galleryd-8232962d857ca88c442e17a7423950d24a3514ee.tar.xz galleryd-8232962d857ca88c442e17a7423950d24a3514ee.zip | |
test(scanner): improve scanner behavior tests
Diffstat (limited to 'internal/scanner')
| -rw-r--r-- | internal/scanner/scanner_test.go | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/internal/scanner/scanner_test.go b/internal/scanner/scanner_test.go index 4027d95..2ada2fd 100644 --- a/internal/scanner/scanner_test.go +++ b/internal/scanner/scanner_test.go @@ -6,17 +6,19 @@ import ( "testing" ) -func TestScan(t *testing.T) { +func TestScanner(t *testing.T) { root := filepath.Join("testdata", "gallery") - s := New([]string{root}) + s := New(Config{ + Roots: []string{root}, + }) files, err := s.Scan(context.Background()) if err != nil { t.Fatalf("Scan failed: %v", err) } - t.Run("Find supported images", func(t *testing.T) { + t.Run("find supported images", func(t *testing.T) { expected := map[string]struct{}{ "cat.jpg": {}, "dog.png": {}, @@ -32,7 +34,7 @@ func TestScan(t *testing.T) { } }) - t.Run("Ignore unsupported files", func(t *testing.T) { + t.Run("ignore unsupported files", func(t *testing.T) { for _, file := range files { switch filepath.Base(file.Path) { case "readme.txt", "jeffsfiles.pdf": @@ -41,7 +43,7 @@ func TestScan(t *testing.T) { } }) - t.Run("Skip hidden directories", func(t *testing.T) { + t.Run("skip hidden directories", func(t *testing.T) { for _, file := range files { if filepath.Base(file.Path) == "nuclearlaunchcode.txt" { t.Fatal("Hidden file entered the scanner") @@ -49,12 +51,14 @@ func TestScan(t *testing.T) { } }) - t.Run("Deduplicates overlapping roots", func(t *testing.T) { + t.Run("deduplicates overlapping roots", func(t *testing.T) { root := filepath.Join("testdata", "duplicate") - s := New([]string{ - root, - root, + s := New(Config{ + Roots: []string{ + root, + root, + }, }) files, err := s.Scan(context.Background()) |