diff options
| author | RanXom <saiyedshizain@gmail.com> | 2026-07-13 01:50:14 +0530 |
|---|---|---|
| committer | RanXom <saiyedshizain@gmail.com> | 2026-07-13 01:50:14 +0530 |
| commit | f6dc29b825d2b24430d1d9831cccdb8275405964 (patch) | |
| tree | 403a0e65d1cd12504982b7cb4edf4c249639bb0c /internal/scanner | |
| parent | eb123dbdbe6799a8fcaf2ab908cd155a7e9efc74 (diff) | |
| download | galleryd-f6dc29b825d2b24430d1d9831cccdb8275405964.tar.xz galleryd-f6dc29b825d2b24430d1d9831cccdb8275405964.zip | |
test(scanner): add test for skipping symlinks
Diffstat (limited to 'internal/scanner')
| -rw-r--r-- | internal/scanner/scanner_test.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/internal/scanner/scanner_test.go b/internal/scanner/scanner_test.go index 2ada2fd..870aab0 100644 --- a/internal/scanner/scanner_test.go +++ b/internal/scanner/scanner_test.go @@ -15,7 +15,7 @@ func TestScanner(t *testing.T) { files, err := s.Scan(context.Background()) if err != nil { - t.Fatalf("Scan failed: %v", err) + t.Fatalf("scan failed: %v", err) } t.Run("find supported images", func(t *testing.T) { @@ -30,7 +30,7 @@ func TestScanner(t *testing.T) { } if len(expected) != 0 { - t.Fatalf("Missing files: %v", expected) + t.Fatalf("missing files: %v", expected) } }) @@ -38,7 +38,7 @@ func TestScanner(t *testing.T) { for _, file := range files { switch filepath.Base(file.Path) { case "readme.txt", "jeffsfiles.pdf": - t.Fatalf("Scanner returned unsupported files %q", file.Path) + t.Fatalf("scanner returned unsupported files %q", file.Path) } } }) @@ -46,7 +46,7 @@ func TestScanner(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") + t.Fatal("hidden file entered the scanner") } } }) @@ -63,11 +63,19 @@ func TestScanner(t *testing.T) { files, err := s.Scan(context.Background()) if err != nil { - t.Fatalf("Scan failed: %v", err) + t.Fatalf("scan failed: %v", err) } if len(files) != 2 { - t.Fatalf("Expected 2 unique files, got %d", len(files)) + t.Fatalf("expected 2 unique files, got %d", len(files)) + } + }) + + t.Run("ignores symbolic links", func(t *testing.T) { + for _, file := range files { + if filepath.Base(file.Path) == "link.jpg" { + t.Fatal("scanner followed symbolic link") + } } }) } |