MCPcopy
hub / github.com/github/gh-ost / TestAbort_AfterRowCopy

Function TestAbort_AfterRowCopy

go/logic/migrator_test.go:1242–1281  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1240}
1241
1242func TestAbort_AfterRowCopy(t *testing.T) {
1243 migrationContext := base.NewMigrationContext()
1244 migrator := NewMigrator(migrationContext, "1.0.0")
1245
1246 // Start listenOnPanicAbort
1247 go migrator.listenOnPanicAbort()
1248
1249 // Give listenOnPanicAbort time to start
1250 time.Sleep(20 * time.Millisecond)
1251
1252 // Simulate row copy error by sending to rowCopyComplete in a goroutine
1253 // (unbuffered channel, so send must be async)
1254 testErr := errors.New("row copy failed")
1255 go func() {
1256 migrator.rowCopyComplete <- testErr
1257 }()
1258
1259 // Consume the error (simulating what Migrate() does)
1260 // This is a blocking call that waits for the error
1261 migrator.consumeRowCopyComplete()
1262
1263 // Wait for the error to be processed by listenOnPanicAbort
1264 time.Sleep(50 * time.Millisecond)
1265
1266 // Check that error was stored
1267 if got := migrationContext.GetAbortError(); got == nil {
1268 t.Fatal("Expected abort error to be stored after row copy error")
1269 } else if got.Error() != "row copy failed" {
1270 t.Errorf("Expected 'row copy failed', got %v", got)
1271 }
1272
1273 // Verify context was cancelled
1274 ctx := migrationContext.GetContext()
1275 select {
1276 case <-ctx.Done():
1277 // Success
1278 case <-time.After(1 * time.Second):
1279 t.Error("Expected context to be cancelled after row copy error")
1280 }
1281}
1282
1283func TestAbort_DuringInspection(t *testing.T) {
1284 migrationContext := base.NewMigrationContext()

Callers

nothing calls this directly

Calls 9

listenOnPanicAbortMethod · 0.95
GetAbortErrorMethod · 0.95
GetContextMethod · 0.95
NewMigrationContextFunction · 0.92
NewMigratorFunction · 0.85
FatalMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…