From 975349b50e3d2c76564fef686a2a33b01212b6d3 Mon Sep 17 00:00:00 2001 From: xengineering Date: Tue, 2 Jun 2026 20:12:53 +0200 Subject: Name tests like functions to test This enforces a similar structure of test functions named `TestFooBar` if they test the function `FooBar`. --- database_test.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/database_test.go b/database_test.go index 66ffc37..d285c95 100644 --- a/database_test.go +++ b/database_test.go @@ -8,21 +8,19 @@ import ( "testing" ) -func TestMigrationNumber(t *testing.T) { +func TestReadMigrations(t *testing.T) { n := len(migrations) entries, err := os.ReadDir(migrationDir) if err != nil { t.Fatalf("Failed to determine number of migration files: %v", err) } - expectation := len(entries) + nMigrationFiles := len(entries) - if n != expectation { - t.Fatalf("Expected %d migration files but got %d.", expectation, n) + if n != nMigrationFiles { + t.Fatalf("Expected %d migration files but got %d.", nMigrationFiles, n) } -} -func TestMigrationContent(t *testing.T) { for i, migration := range migrations { path := migrationPath(i) @@ -33,7 +31,7 @@ func TestMigrationContent(t *testing.T) { } } -func TestMigrations(t *testing.T) { +func TestMigrate(t *testing.T) { db, _ := emptyDB(t) userVersion, err := UserVersion(db) -- cgit v1.3.1