From 929cce1bb81f86d8b05f237f8d9c79ee70c9b1a2 Mon Sep 17 00:00:00 2001 From: Muhammad Abduh Date: Mon, 7 Aug 2023 17:12:33 +0700 Subject: [PATCH] fix: recursive expand parents --- core/receiver/service.go | 2 +- core/receiver/service_test.go | 22 ++++------------------ 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/core/receiver/service.go b/core/receiver/service.go index 45b6a5ca..398b82d4 100644 --- a/core/receiver/service.go +++ b/core/receiver/service.go @@ -218,7 +218,7 @@ func (s *Service) ExpandParents(ctx context.Context, rcvs []Receiver) ([]Receive uniqueParentIDs = append(uniqueParentIDs, k) } - parentReceivers, err := s.List(ctx, Filter{ReceiverIDs: uniqueParentIDs, Expanded: true}) + parentReceivers, err := s.List(ctx, Filter{ReceiverIDs: uniqueParentIDs, Expanded: false}) if err != nil { return nil, fmt.Errorf("failure when expanding receiver parents: %w", err) } diff --git a/core/receiver/service_test.go b/core/receiver/service_test.go index a8c93ca9..7c074966 100644 --- a/core/receiver/service_test.go +++ b/core/receiver/service_test.go @@ -674,7 +674,7 @@ func TestService_ExpandParents(t *testing.T) { Setup: func(rr *mocks.ReceiverRepository, ss *mocks.ConfigResolver, sc *mocks.ConfigResolver) { rr.EXPECT().List(mock.AnythingOfType("*context.emptyCtx"), receiver.Filter{ ReceiverIDs: []uint64{1, 2}, - Expanded: true, + Expanded: false, }).Return([]receiver.Receiver{ { ID: 1, @@ -705,20 +705,6 @@ func TestService_ExpandParents(t *testing.T) { UpdatedAt: timeNow, }, }, nil) - ss.EXPECT().PostHookDBTransformConfigs(mock.AnythingOfType("*context.emptyCtx"), map[string]any{ - "token": "key1", - "workspace": "company1", - }).Return(map[string]any{ - "token": "decrypted_key1", - "workspace": "company1", - }, nil) - ss.EXPECT().PostHookDBTransformConfigs(mock.AnythingOfType("*context.emptyCtx"), map[string]any{ - "token": "key2", - "workspace": "company2", - }).Return(map[string]any{ - "token": "decrypted_key2", - "workspace": "company2", - }, nil) }, Receivers: sampleReceivers, ExpandedReceivers: []receiver.Receiver{ @@ -726,7 +712,7 @@ func TestService_ExpandParents(t *testing.T) { ID: 3, Configurations: map[string]any{ "channel_name": "my-channel", - "token": "decrypted_key1", + "token": "key1", "workspace": "company1", }, ParentID: 1, @@ -735,7 +721,7 @@ func TestService_ExpandParents(t *testing.T) { ID: 4, Configurations: map[string]any{ "channel_name": "any-channel", - "token": "decrypted_key2", + "token": "key2", "workspace": "company2", }, ParentID: 2, @@ -744,7 +730,7 @@ func TestService_ExpandParents(t *testing.T) { ID: 5, Configurations: map[string]any{ "channel_name": "my-channel", - "token": "decrypted_key2", + "token": "key2", "workspace": "company2", }, ParentID: 2,