Skip to content

Commit 4cb45b8

Browse files
committed
Fix Deactivation of Flows To Be Deleted
1 parent 482c578 commit 4cb45b8

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

command/smart_flow.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,13 @@ func processDestructiveFile(q flowQuerier, fileContent []byte, files ForceMetada
123123
// First pass: Get the actual API name from the org (with correct casing)
124124
var actualApiName string
125125
for _, rec := range qr.Records {
126-
if actualApiName == "" && rec["FlowDefinitionView.ApiName"] != nil {
127-
actualApiName = rec["FlowDefinitionView.ApiName"].(string)
128-
break
126+
if actualApiName == "" {
127+
if flowDef, ok := rec["FlowDefinitionView"].(map[string]interface{}); ok {
128+
if apiName, ok := flowDef["ApiName"].(string); ok {
129+
actualApiName = apiName
130+
break
131+
}
132+
}
129133
}
130134
}
131135

command/smart_flow_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,9 @@ func TestProcessDestructiveFlows_WithVersions(t *testing.T) {
271271
flowName := "TestFlow"
272272
fq := &fakeQuerier{results: map[string]lib.ForceQueryResult{
273273
flowName: {Records: []lib.ForceRecord{
274-
{"VersionNumber": float64(1), "Status": "Active", "FlowDefinitionView.ApiName": "TestFlow"},
275-
{"VersionNumber": float64(2), "Status": "Inactive", "FlowDefinitionView.ApiName": "TestFlow"},
276-
{"VersionNumber": float64(3), "Status": "Active", "FlowDefinitionView.ApiName": "TestFlow"},
274+
{"VersionNumber": float64(1), "Status": "Active", "FlowDefinitionView": map[string]interface{}{"ApiName": "TestFlow"}},
275+
{"VersionNumber": float64(2), "Status": "Inactive", "FlowDefinitionView": map[string]interface{}{"ApiName": "TestFlow"}},
276+
{"VersionNumber": float64(3), "Status": "Active", "FlowDefinitionView": map[string]interface{}{"ApiName": "TestFlow"}},
277277
}},
278278
}}
279279

@@ -423,7 +423,7 @@ func TestProcessDestructiveFlows_NoVersions(t *testing.T) {
423423
func TestProcessDestructiveFlows_MixedFlows(t *testing.T) {
424424
fq := &fakeQuerier{results: map[string]lib.ForceQueryResult{
425425
"FlowWithVersions": {Records: []lib.ForceRecord{
426-
{"VersionNumber": float64(1), "Status": "Active", "FlowDefinitionView.ApiName": "FlowWithVersions"},
426+
{"VersionNumber": float64(1), "Status": "Active", "FlowDefinitionView": map[string]interface{}{"ApiName": "FlowWithVersions"}},
427427
}},
428428
"FlowWithoutVersions": {Records: []lib.ForceRecord{}},
429429
}}
@@ -496,8 +496,8 @@ func TestProcessDestructiveFlows_CaseMismatch(t *testing.T) {
496496
// Org has flow with name "MyFlow" but destructive changes has "myflow"
497497
fq := &fakeQuerier{results: map[string]lib.ForceQueryResult{
498498
"myflow": {Records: []lib.ForceRecord{
499-
{"VersionNumber": float64(1), "Status": "Active", "FlowDefinitionView.ApiName": "MyFlow"},
500-
{"VersionNumber": float64(2), "Status": "Inactive", "FlowDefinitionView.ApiName": "MyFlow"},
499+
{"VersionNumber": float64(1), "Status": "Active", "FlowDefinitionView": map[string]interface{}{"ApiName": "MyFlow"}},
500+
{"VersionNumber": float64(2), "Status": "Inactive", "FlowDefinitionView": map[string]interface{}{"ApiName": "MyFlow"}},
501501
}},
502502
}}
503503

@@ -568,12 +568,12 @@ func TestProcessDestructiveFlows_DuplicateCasing(t *testing.T) {
568568
// Both queries return the same flow (with correct casing from org)
569569
fq := &fakeQuerier{results: map[string]lib.ForceQueryResult{
570570
"Member_Plan_After_Save": {Records: []lib.ForceRecord{
571-
{"VersionNumber": float64(2), "Status": "Active", "FlowDefinitionView.ApiName": "Member_Plan_After_save"},
572-
{"VersionNumber": float64(3), "Status": "Inactive", "FlowDefinitionView.ApiName": "Member_Plan_After_save"},
571+
{"VersionNumber": float64(2), "Status": "Active", "FlowDefinitionView": map[string]interface{}{"ApiName": "Member_Plan_After_save"}},
572+
{"VersionNumber": float64(3), "Status": "Inactive", "FlowDefinitionView": map[string]interface{}{"ApiName": "Member_Plan_After_save"}},
573573
}},
574574
"Member_Plan_After_save": {Records: []lib.ForceRecord{
575-
{"VersionNumber": float64(2), "Status": "Active", "FlowDefinitionView.ApiName": "Member_Plan_After_save"},
576-
{"VersionNumber": float64(3), "Status": "Inactive", "FlowDefinitionView.ApiName": "Member_Plan_After_save"},
575+
{"VersionNumber": float64(2), "Status": "Active", "FlowDefinitionView": map[string]interface{}{"ApiName": "Member_Plan_After_save"}},
576+
{"VersionNumber": float64(3), "Status": "Inactive", "FlowDefinitionView": map[string]interface{}{"ApiName": "Member_Plan_After_save"}},
577577
}},
578578
}}
579579

@@ -653,12 +653,12 @@ func TestProcessDestructiveFlows_DuplicateCasing(t *testing.T) {
653653
func TestProcessDestructiveFlows_NoFlowDefinitionForInactiveOnly(t *testing.T) {
654654
fq := &fakeQuerier{results: map[string]lib.ForceQueryResult{
655655
"InactiveOnlyFlow": {Records: []lib.ForceRecord{
656-
{"VersionNumber": float64(1), "Status": "Inactive", "FlowDefinitionView.ApiName": "InactiveOnlyFlow"},
657-
{"VersionNumber": float64(2), "Status": "Obsolete", "FlowDefinitionView.ApiName": "InactiveOnlyFlow"},
656+
{"VersionNumber": float64(1), "Status": "Inactive", "FlowDefinitionView": map[string]interface{}{"ApiName": "InactiveOnlyFlow"}},
657+
{"VersionNumber": float64(2), "Status": "Obsolete", "FlowDefinitionView": map[string]interface{}{"ApiName": "InactiveOnlyFlow"}},
658658
}},
659659
"ActiveFlow": {Records: []lib.ForceRecord{
660-
{"VersionNumber": float64(1), "Status": "Active", "FlowDefinitionView.ApiName": "ActiveFlow"},
661-
{"VersionNumber": float64(2), "Status": "Inactive", "FlowDefinitionView.ApiName": "ActiveFlow"},
660+
{"VersionNumber": float64(1), "Status": "Active", "FlowDefinitionView": map[string]interface{}{"ApiName": "ActiveFlow"}},
661+
{"VersionNumber": float64(2), "Status": "Inactive", "FlowDefinitionView": map[string]interface{}{"ApiName": "ActiveFlow"}},
662662
}},
663663
}}
664664

0 commit comments

Comments
 (0)