File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -486,11 +486,12 @@ export class PgStoreV2 extends BasePgStoreModule {
486486 OFFSET ${ offset }
487487 LIMIT ${ limit }
488488 ` ;
489+ const total = results . length > 0 ? results [ 0 ] . total : 0 ;
489490 return {
490491 limit,
491492 offset,
492493 results : results ,
493- total : results [ 0 ] . total ,
494+ total,
494495 } ;
495496 } ) ;
496497 }
Original file line number Diff line number Diff line change @@ -4,13 +4,15 @@ import { ChainID } from '@stacks/common';
44import { ApiServer , startApiServer } from '../api/init' ;
55import { PgWriteStore } from '../datastore/pg-write-store' ;
66import { importEventsFromTsv } from '../event-replay/event-replay' ;
7+ import { migrate } from '../test-utils/test-helpers' ;
78
89describe ( 'PoX tests' , ( ) => {
910 let db : PgWriteStore ;
1011 let client : PgSqlClient ;
1112 let api : ApiServer ;
1213
1314 beforeEach ( async ( ) => {
15+ await migrate ( 'up' ) ;
1416 db = await PgWriteStore . connect ( {
1517 usageName : 'tests' ,
1618 withNotifier : true ,
@@ -23,6 +25,18 @@ describe('PoX tests', () => {
2325 afterEach ( async ( ) => {
2426 await api . terminate ( ) ;
2527 await db ?. close ( ) ;
28+ await migrate ( 'down' ) ;
29+ } ) ;
30+
31+ test ( 'api with empty cycles' , async ( ) => {
32+ const cycles0 = await supertest ( api . server ) . get ( `/extended/v2/pox/cycles` ) ;
33+ expect ( cycles0 . status ) . toBe ( 200 ) ;
34+ expect ( JSON . parse ( cycles0 . text ) ) . toStrictEqual ( {
35+ limit : 20 ,
36+ offset : 0 ,
37+ results : [ ] ,
38+ total : 0 ,
39+ } ) ;
2640 } ) ;
2741
2842 test ( 'api' , async ( ) => {
You can’t perform that action at this time.
0 commit comments