From 8232962d857ca88c442e17a7423950d24a3514ee Mon Sep 17 00:00:00 2001 From: RanXom Date: Mon, 13 Jul 2026 01:40:30 +0530 Subject: test(scanner): improve scanner behavior tests --- internal/scanner/scanner_test.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'internal') 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()) -- cgit v1.2.3