44 "context"
55 "os"
66 "path/filepath"
7+ "strings"
78 "testing"
89
910 "github.com/jackc/pgconn"
@@ -37,7 +38,7 @@ func TestRepairCommand(t *testing.T) {
3738 conn := pgtest .NewConn ()
3839 defer conn .Close (t )
3940 helper .MockMigrationHistory (conn ).
40- Query (migration .INSERT_MIGRATION_VERSION , "0" , "test" , []string {"select 1" }).
41+ Query (migration .UPSERT_MIGRATION_VERSION , "0" , "test" , []string {"select 1" }).
4142 Reply ("INSERT 0 1" )
4243 // Run test
4344 err := Run (context .Background (), dbConfig , []string {"0" }, Applied , fsys , conn .Intercept )
@@ -87,7 +88,7 @@ func TestRepairCommand(t *testing.T) {
8788 conn := pgtest .NewConn ()
8889 defer conn .Close (t )
8990 helper .MockMigrationHistory (conn ).
90- Query (migration .INSERT_MIGRATION_VERSION , "0" , "test" , nil ).
91+ Query (migration .UPSERT_MIGRATION_VERSION , "0" , "test" , nil ).
9192 ReplyError (pgerrcode .DuplicateObject , `relation "supabase_migrations.schema_migrations" does not exist` )
9293 // Run test
9394 err := Run (context .Background (), dbConfig , []string {"0" }, Applied , fsys , conn .Intercept )
@@ -107,7 +108,10 @@ func TestRepairAll(t *testing.T) {
107108 conn := pgtest .NewConn ()
108109 defer conn .Close (t )
109110 helper .MockMigrationHistory (conn ).
110- Query (migration .TRUNCATE_VERSION_TABLE + `;INSERT INTO supabase_migrations.schema_migrations(version, name, statements) VALUES( '0' , 'test' , '{select 1}' )` ).
111+ Query (strings .Join ([]string {
112+ migration .TRUNCATE_VERSION_TABLE ,
113+ strings .ReplaceAll (migration .UPSERT_MIGRATION_VERSION , "$1, $2, $3" , " '0' , 'test' , '{select 1}' " ),
114+ }, ";" )).
111115 Reply ("TRUNCATE TABLE" ).
112116 Reply ("INSERT 0 1" )
113117 // Run test
0 commit comments