Skip to content

Commit

Permalink
Merge pull request #885 from alfrunes/4.5.x
Browse files Browse the repository at this point in the history
fix: Delete device deployment history incorrectly triggering reindex
  • Loading branch information
tranchitella committed Jul 13, 2023
2 parents a166a62 + 45d358e commit 8ab255c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,10 @@ func (d *Deployments) DeleteDeviceDeploymentsHistory(ctx context.Context, device
deviceDeployments[i].DeviceID = d.DeviceId
deviceDeployments[i].DeploymentID = d.DeploymentId
}
return d.workflowsClient.StartReindexReportingDeploymentBatch(ctx, deviceDeployments)
if d.reportingClient != nil {
err = d.workflowsClient.StartReindexReportingDeploymentBatch(ctx, deviceDeployments)
}
return err
}

// Storage settings
Expand Down
3 changes: 3 additions & 0 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1278,11 +1278,14 @@ func TestDeleteDeviceDeploymentsHistory(t *testing.T) {
for name, tc := range testCases {
t.Run(fmt.Sprintf("test case %s", name), func(t *testing.T) {

rc := new(reporting_mocks.Client)
defer rc.AssertExpectations(t)
defer tc.workflowsMock.AssertExpectations(t)
defer tc.storeMock.AssertExpectations(t)
ds := &Deployments{
db: tc.storeMock,
workflowsClient: tc.workflowsMock,
reportingClient: rc,
}

err := ds.DeleteDeviceDeploymentsHistory(ctx, deviceID)
Expand Down

0 comments on commit 8ab255c

Please sign in to comment.