Skip to content

Commit

Permalink
tests: fix ws tests
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Gateru <[email protected]>
  • Loading branch information
felixgateru committed Jan 30, 2025
1 parent f1aeccf commit db903c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
12 changes: 5 additions & 7 deletions journal/postgres/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,15 @@ func (repo *repository) IncrementOutboundMessages(ctx context.Context, channelID
var clientID string
var count uint64
if err = rows.Scan(&clientID, &count); err != nil {
err := tx.Rollback()
if err == nil {
return postgres.HandleError(repoerr.ErrUpdateEntity, err)
if err := tx.Rollback(); err != nil {
return errors.Wrap(errors.ErrRollbackTx, err)
}
return errors.Wrap(errors.ErrRollbackTx, err)
return postgres.HandleError(repoerr.ErrUpdateEntity, err)

Check warning on line 194 in journal/postgres/telemetry.go

View check run for this annotation

Codecov / codecov/patch

journal/postgres/telemetry.go#L182-L194

Added lines #L182 - L194 were not covered by tests
}

if _, err = repo.db.ExecContext(ctx, q, count, clientID); err != nil {
err := tx.Rollback()
if err == nil {
return postgres.HandleError(repoerr.ErrUpdateEntity, err)
if err := tx.Rollback(); err != nil {
return errors.Wrap(errors.ErrRollbackTx, err)
}
return errors.Wrap(errors.ErrRollbackTx, err)

Check warning on line 201 in journal/postgres/telemetry.go

View check run for this annotation

Codecov / codecov/patch

journal/postgres/telemetry.go#L197-L201

Added lines #L197 - L201 were not covered by tests
}
Expand Down
7 changes: 4 additions & 3 deletions ws/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ func TestSubscribe(t *testing.T) {

for _, tc := range cases {
subConfig := messaging.SubscriberConfig{
ID: clientID,
Topic: "channels." + tc.chanID + "." + subTopic,
Handler: c,
ID: clientID,
Topic: "channels." + tc.chanID + "." + subTopic,
ClientID: clientID,
Handler: c,
}
clientsCall := clients.On("Authenticate", mock.Anything, &grpcClientsV1.AuthnReq{ClientSecret: tc.clientKey}).Return(tc.authNRes, tc.authNErr)
channelsCall := channels.On("Authorize", mock.Anything, &grpcChannelsV1.AuthzReq{
Expand Down

0 comments on commit db903c4

Please sign in to comment.