From 8032ea682b0875433befa90400afb2a63d2f4c56 Mon Sep 17 00:00:00 2001 From: clawbot <35+clawbot@noreply.example.org> Date: Sun, 4 Oct 2026 13:30:23 +0200 Subject: [PATCH] Test that scan refuses another schema version (closes #64) The version-mismatch test only opened its database through openReportDatabase, so nothing exercised the branch of initSchema that stops scan on a database stamped with an unknown schema version. The test now opens the same database through openScanDatabase too and requires errSchemaVersion, and is renamed to match the unversioned-file test beside it, which also covers both paths. Model: opus-5-5 --- TODO.md | 3 +++ db_test.go | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 57c7daf..d824ca3 100644 --- a/TODO.md +++ b/TODO.md @@ -29,6 +29,9 @@ # Completed Steps +- test that `scan` refuses a database with another schema version + (2026-10-04, https://git.eeqj.de/sneak/sfdupes/issues/64) + - correct four inaccurate comments in `cancel_test.go` and rename `walkCancelInFlightDirs` to `walkCancelInFlightFiles` (2026-10-04, https://git.eeqj.de/sneak/sfdupes/issues/33) diff --git a/db_test.go b/db_test.go index 2fc6df5..ef7e833 100644 --- a/db_test.go +++ b/db_test.go @@ -157,9 +157,11 @@ func TestOpenReportDatabaseMissing(t *testing.T) { } } -func TestOpenReportDatabaseVersionMismatch(t *testing.T) { +func TestOpenDatabaseVersionMismatch(t *testing.T) { t.Parallel() + // A database stamped with a schema version other than 0 and + // schemaVersion. report, trees and scan must all refuse it. path := testDBPath(t) db, err := openScanDatabase(t.Context(), path) @@ -176,7 +178,12 @@ func TestOpenReportDatabaseVersionMismatch(t *testing.T) { _, err = openReportDatabase(t.Context(), path) if !errors.Is(err, errSchemaVersion) { - t.Fatalf("err = %v, want errSchemaVersion", err) + t.Fatalf("report: err = %v, want errSchemaVersion", err) + } + + _, err = openScanDatabase(t.Context(), path) + if !errors.Is(err, errSchemaVersion) { + t.Fatalf("scan: err = %v, want errSchemaVersion", err) } }