Skip to content

Commit

Permalink
fix: GetSubscriptions ASC
Browse files Browse the repository at this point in the history
  • Loading branch information
agparadiso committed Jan 4, 2024
1 parent eab3d1f commit 9a9cf1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/services/gateway/handlers/functions/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (o *orm) GetSubscriptions(offset, limit uint, qopts ...pg.QOpt) ([]CachedSu
SELECT subscription_id, owner, balance, blocked_balance, proposed_owner, consumers, flags, router_contract_address
FROM %s
WHERE router_contract_address = $1
ORDER BY subscription_id DESC
ORDER BY subscription_id ASC
OFFSET $2
LIMIT $3;
`, tableName)
Expand Down
8 changes: 4 additions & 4 deletions core/services/gateway/handlers/functions/orm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestORM_GetSubscriptions(t *testing.T) {
results, err := orm.GetSubscriptions(0, 1)
require.NoError(t, err)
require.Equal(t, 1, len(results), "incorrect results length")
require.Equal(t, cachedSubscriptions[0], results[0])
require.Equal(t, cachedSubscriptions[1], results[0])
})

t.Run("fetch second page", func(t *testing.T) {
Expand All @@ -70,7 +70,7 @@ func TestORM_GetSubscriptions(t *testing.T) {
results, err := orm.GetSubscriptions(1, 5)
require.NoError(t, err)
require.Equal(t, 1, len(results), "incorrect results length")
require.Equal(t, cachedSubscriptions[1], results[0])
require.Equal(t, cachedSubscriptions[0], results[0])
})
}

Expand Down Expand Up @@ -140,8 +140,8 @@ func TestORM_UpsertSubscription(t *testing.T) {
results, err := orm.GetSubscriptions(0, 5)
require.NoError(t, err)
require.Equal(t, 2, len(results), "incorrect results length")
require.Equal(t, expectedNotUpdated, results[0])
require.Equal(t, expectedUpdated, results[1])
require.Equal(t, expectedNotUpdated, results[1])
require.Equal(t, expectedUpdated, results[0])
})

t.Run("update a deleted subscription", func(t *testing.T) {
Expand Down

0 comments on commit 9a9cf1a

Please sign in to comment.