client: remove unused nsd check allocation result diff func (#17695)

This commit is contained in:
James Rasell
2023-06-23 16:26:06 +02:00
committed by GitHub
parent 5b5fbc0881
commit ced6c5890e
2 changed files with 0 additions and 51 deletions

View File

@@ -88,17 +88,6 @@ func Stub(
// checks in an allocation.
type AllocationResults map[structs.CheckID]*structs.CheckQueryResult
// diff returns the set of IDs in ids that are not in m.
func (m AllocationResults) diff(ids []structs.CheckID) []structs.CheckID {
var missing []structs.CheckID
for _, id := range ids {
if _, exists := m[id]; !exists {
missing = append(missing, id)
}
}
return missing
}
// ClientResults is a holistic view of alloc_id -> check_id -> latest result
// group and task checks across all allocations on a client.
type ClientResults map[string]AllocationResults

View File

@@ -111,46 +111,6 @@ func TestChecks_Stub(t *testing.T) {
}, result)
}
func TestChecks_AllocationResults_diff(t *testing.T) {
cases := []struct {
name string
results []structs.CheckID
ids []structs.CheckID
exp []structs.CheckID
}{{
name: "empty results and empty ids",
results: nil,
ids: nil,
exp: nil,
}, {
name: "empty results and nonempty ids",
results: nil,
ids: []structs.CheckID{"aaa", "bbb"},
exp: []structs.CheckID{"aaa", "bbb"},
}, {
name: "nonempty results and empty ids",
results: []structs.CheckID{"aaa", "bbb"},
ids: nil,
exp: nil,
}, {
name: "mix",
results: []structs.CheckID{"aaa", "ccc", "ddd", "fff"},
ids: []structs.CheckID{"bbb", "ccc", "fff", "eee"},
exp: []structs.CheckID{"bbb", "eee"},
}}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
ar := make(AllocationResults)
for _, id := range tc.results {
ar[id] = nil
}
result := ar.diff(tc.ids)
must.Eq(t, tc.exp, result)
})
}
}
func TestChecks_ClientResults_Insert(t *testing.T) {
cr := make(ClientResults)
cr.Insert("alloc1", &structs.CheckQueryResult{ID: "qr1", Check: "c1"})