From ced6c5890e39b97e0c8af670d5cf6e4c63ccec7a Mon Sep 17 00:00:00 2001 From: James Rasell Date: Fri, 23 Jun 2023 16:26:06 +0200 Subject: [PATCH] client: remove unused nsd check allocation result diff func (#17695) --- client/serviceregistration/checks/result.go | 11 ----- .../serviceregistration/checks/result_test.go | 40 ------------------- 2 files changed, 51 deletions(-) diff --git a/client/serviceregistration/checks/result.go b/client/serviceregistration/checks/result.go index eaaa89a1e..14b492f43 100644 --- a/client/serviceregistration/checks/result.go +++ b/client/serviceregistration/checks/result.go @@ -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 diff --git a/client/serviceregistration/checks/result_test.go b/client/serviceregistration/checks/result_test.go index 6d88c5c58..d4e0704de 100644 --- a/client/serviceregistration/checks/result_test.go +++ b/client/serviceregistration/checks/result_test.go @@ -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"})