(t *testing.T)
| 210 | } |
| 211 | |
| 212 | func TestPlanSpecRemove_EmitsIssueComment(t *testing.T) { |
| 213 | t.Parallel() |
| 214 | a := require.New(t) |
| 215 | f := setupPlanUpdateFixture(t, true) |
| 216 | |
| 217 | originalSpec := f.plan.Specs[0] |
| 218 | secondSpecID := uuid.NewString() |
| 219 | // Seed: add a second spec we can later remove. |
| 220 | _, err := f.ctl.planServiceClient.UpdatePlan(f.ctx, connect.NewRequest(&v1pb.UpdatePlanRequest{ |
| 221 | Plan: &v1pb.Plan{ |
| 222 | Name: f.plan.Name, |
| 223 | Specs: []*v1pb.Plan_Spec{ |
| 224 | originalSpec, |
| 225 | { |
| 226 | Id: secondSpecID, |
| 227 | Config: &v1pb.Plan_Spec_ChangeDatabaseConfig{ |
| 228 | ChangeDatabaseConfig: &v1pb.Plan_ChangeDatabaseConfig{ |
| 229 | Targets: []string{f.database.Name}, |
| 230 | Sheet: f.sheet2.Name, |
| 231 | }, |
| 232 | }, |
| 233 | }, |
| 234 | }, |
| 235 | }, |
| 236 | UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"specs"}}, |
| 237 | })) |
| 238 | a.NoError(err) |
| 239 | |
| 240 | // Now remove the second spec. |
| 241 | _, err = f.ctl.planServiceClient.UpdatePlan(f.ctx, connect.NewRequest(&v1pb.UpdatePlanRequest{ |
| 242 | Plan: &v1pb.Plan{ |
| 243 | Name: f.plan.Name, |
| 244 | Specs: []*v1pb.Plan_Spec{originalSpec}, |
| 245 | }, |
| 246 | UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"specs"}}, |
| 247 | })) |
| 248 | a.NoError(err) |
| 249 | |
| 250 | events := listPlanUpdateEvents(t, f) |
| 251 | a.Len(events, 2, "expected two PlanUpdate rows: seed add + removal") |
| 252 | removal := events[1] |
| 253 | a.Len(removal.FromSpecs, 2) |
| 254 | a.Len(removal.ToSpecs, 1) |
| 255 | a.Equal(originalSpec.Id, removal.ToSpecs[0].Id) |
| 256 | idsBefore := map[string]bool{} |
| 257 | for _, s := range removal.FromSpecs { |
| 258 | idsBefore[s.Id] = true |
| 259 | } |
| 260 | a.True(idsBefore[secondSpecID]) |
| 261 | } |
| 262 | |
| 263 | func TestPlanSpecUpdate_TargetsChange_EmitsIssueComment(t *testing.T) { |
| 264 | t.Parallel() |
nothing calls this directly
no test coverage detected