mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
Hotfix: add empty host slice validation in ListHosts (#13483)
This commit is contained in:
parent
699701a2db
commit
29e48f402a
2 changed files with 9 additions and 0 deletions
|
|
@ -748,6 +748,10 @@ func (ds *Datastore) CleanupPolicyMembership(ctx context.Context, now time.Time)
|
|||
}
|
||||
|
||||
func (ds *Datastore) UpdatePolicyFailureCountsForHosts(ctx context.Context, hosts []*fleet.Host) ([]*fleet.Host, error) {
|
||||
if len(hosts) == 0 {
|
||||
return hosts, nil
|
||||
}
|
||||
|
||||
// Get policy failure counts for each host
|
||||
hostIDs := make([]uint, 0, len(hosts))
|
||||
|
||||
|
|
|
|||
|
|
@ -2271,4 +2271,9 @@ func testUpdatePolicyFailureCountsForHosts(t *testing.T, ds *Datastore) {
|
|||
// host 3 doesn't have any policy membership
|
||||
assert.Equal(t, 0, hostsUpdated[3].TotalIssuesCount)
|
||||
assert.Equal(t, 0, hostsUpdated[3].FailingPoliciesCount)
|
||||
|
||||
// return empty list if no hosts are passed
|
||||
hostsUpdated, err = ds.UpdatePolicyFailureCountsForHosts(ctx, []*fleet.Host{})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, hostsUpdated, 0)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue