(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestMigrator_AddSQL_and_Run(t *testing.T) { |
| 10 | db := setupTestDB(t) // reuse from sqlite_test.go |
| 11 | m := storage.NewMigrator(db) |
| 12 | |
| 13 | m.AddSQL("test", "001_create_test.sql", "CREATE TABLE test_table (id INTEGER PRIMARY KEY, name TEXT)") |
| 14 | |
| 15 | if err := m.Run(); err != nil { |
| 16 | t.Fatalf("Run: %v", err) |
| 17 | } |
| 18 | |
| 19 | // Verify table was created |
| 20 | _, err := db.Exec("INSERT INTO test_table (id, name) VALUES (1, 'hello')") |
| 21 | if err != nil { |
| 22 | t.Fatalf("table not created: %v", err) |
| 23 | } |
| 24 | |
| 25 | // Verify migration is tracked |
| 26 | var count int |
| 27 | db.QueryRow("SELECT COUNT(*) FROM migrations WHERE name = ?", "test/001_create_test.sql").Scan(&count) |
| 28 | if count != 1 { |
| 29 | t.Errorf("migration not tracked, count = %d", count) |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | func TestMigrator_SkipsAlreadyApplied(t *testing.T) { |
| 34 | db := setupTestDB(t) |
nothing calls this directly
no test coverage detected