mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
client: remove unused nsd check allocation result diff func (#17695)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"})
|
||||
|
||||
Reference in New Issue
Block a user