TestPlanUpdate_MultiSpec_OneRow verifies that mutating multiple specs in one UpdatePlan call produces exactly one PlanUpdate row whose snapshots capture all the changes.
(t *testing.T)
| 419 | // in one UpdatePlan call produces exactly one PlanUpdate row whose |
| 420 | // snapshots capture all the changes. |
| 421 | func TestPlanUpdate_MultiSpec_OneRow(t *testing.T) { |
| 422 | t.Parallel() |
| 423 | a := require.New(t) |
| 424 | f := setupPlanUpdateFixture(t, true) |
| 425 | |
| 426 | // Seed: add a second spec. |
| 427 | originalSpec := f.plan.Specs[0] |
| 428 | secondSpecID := uuid.NewString() |
| 429 | _, err := f.ctl.planServiceClient.UpdatePlan(f.ctx, connect.NewRequest(&v1pb.UpdatePlanRequest{ |
| 430 | Plan: &v1pb.Plan{ |
| 431 | Name: f.plan.Name, |
| 432 | Specs: []*v1pb.Plan_Spec{ |
| 433 | originalSpec, |
| 434 | { |
| 435 | Id: secondSpecID, |
| 436 | Config: &v1pb.Plan_Spec_ChangeDatabaseConfig{ |
| 437 | ChangeDatabaseConfig: &v1pb.Plan_ChangeDatabaseConfig{ |
| 438 | Targets: []string{f.database.Name}, |
| 439 | Sheet: f.sheet1.Name, |
| 440 | }, |
| 441 | }, |
| 442 | }, |
| 443 | }, |
| 444 | }, |
| 445 | UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"specs"}}, |
| 446 | })) |
| 447 | a.NoError(err) |
| 448 | |
| 449 | // Multi-mutation: change spec 1's sheet AND toggle spec 2's prior_backup. |
| 450 | _, err = f.ctl.planServiceClient.UpdatePlan(f.ctx, connect.NewRequest(&v1pb.UpdatePlanRequest{ |
| 451 | Plan: &v1pb.Plan{ |
| 452 | Name: f.plan.Name, |
| 453 | Specs: []*v1pb.Plan_Spec{ |
| 454 | { |
| 455 | Id: originalSpec.Id, |
| 456 | Config: &v1pb.Plan_Spec_ChangeDatabaseConfig{ |
| 457 | ChangeDatabaseConfig: &v1pb.Plan_ChangeDatabaseConfig{ |
| 458 | Targets: []string{f.database.Name}, |
| 459 | Sheet: f.sheet2.Name, // changed |
| 460 | }, |
| 461 | }, |
| 462 | }, |
| 463 | { |
| 464 | Id: secondSpecID, |
| 465 | Config: &v1pb.Plan_Spec_ChangeDatabaseConfig{ |
| 466 | ChangeDatabaseConfig: &v1pb.Plan_ChangeDatabaseConfig{ |
| 467 | Targets: []string{f.database.Name}, |
| 468 | Sheet: f.sheet1.Name, |
| 469 | EnablePriorBackup: true, // flipped |
| 470 | }, |
| 471 | }, |
| 472 | }, |
| 473 | }, |
| 474 | }, |
| 475 | UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"specs"}}, |
| 476 | })) |
| 477 | a.NoError(err) |
| 478 |
nothing calls this directly
no test coverage detected