Skip to content

Commit

Permalink
fix: recursive expand parents
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdh committed Aug 7, 2023
1 parent ce0b6fe commit 929cce1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion core/receiver/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
22 changes: 4 additions & 18 deletions core/receiver/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -705,28 +705,14 @@ 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{
{
ID: 3,
Configurations: map[string]any{
"channel_name": "my-channel",
"token": "decrypted_key1",
"token": "key1",
"workspace": "company1",
},
ParentID: 1,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 929cce1

Please sign in to comment.