MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestPlanUpdate_MultiSpec_OneRow

Function TestPlanUpdate_MultiSpec_OneRow

backend/tests/plan_update_test.go:421–496  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

419// in one UpdatePlan call produces exactly one PlanUpdate row whose
420// snapshots capture all the changes.
421func 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

Callers

nothing calls this directly

Calls 8

setupPlanUpdateFixtureFunction · 0.85
listPlanUpdateEventsFunction · 0.85
LenMethod · 0.80
UpdatePlanMethod · 0.65
EqualMethod · 0.65
GetSheetMethod · 0.65
GetEnablePriorBackupMethod · 0.45

Tested by

no test coverage detected