(t *testing.T)
| 1240 | } |
| 1241 | |
| 1242 | func 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 | |
| 1283 | func TestAbort_DuringInspection(t *testing.T) { |
| 1284 | migrationContext := base.NewMigrationContext() |
nothing calls this directly
no test coverage detected
searching dependent graphs…