MCPcopy Create free account
hub / github.com/buggregator/server / TestMigrator_AddSQL_and_Run

Function TestMigrator_AddSQL_and_Run

internal/storage/migrator_test.go:9–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func 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
33func TestMigrator_SkipsAlreadyApplied(t *testing.T) {
34 db := setupTestDB(t)

Callers

nothing calls this directly

Calls 5

AddSQLMethod · 0.95
RunMethod · 0.95
NewMigratorFunction · 0.92
ScanMethod · 0.80
setupTestDBFunction · 0.70

Tested by

no test coverage detected