File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -1202,17 +1202,18 @@ describe('Collection', () => {
1202
1202
} ) ;
1203
1203
1204
1204
describe ( 'totalSize' , ( ) => {
1205
- let result ;
1206
-
1207
- beforeEach ( ( ) => {
1208
- result = { storageSize : 1000 , totalIndexSize : 1000 } ;
1209
- serviceProvider . stats . resolves ( result ) ;
1210
- } ) ;
1211
-
1212
1205
it ( 'returns sum of storageSize and totalIndexSize' , async ( ) => {
1206
+ const result = { storageSize : 1000 , totalIndexSize : 1000 } ;
1207
+ serviceProvider . stats . resolves ( result ) ;
1213
1208
expect ( await collection . totalSize ( ) ) . to . equal ( 2000 ) ;
1214
1209
expect ( serviceProvider . stats ) . to . have . been . calledOnceWith ( 'db1' , 'coll1' ) ;
1215
1210
} ) ;
1211
+ it ( 'should handle Long numbers correctly' , async ( ) => {
1212
+ const result = { storageSize : bson . Long . fromNumber ( 1732749910016 ) , totalIndexSize : 10559533056 } ;
1213
+ serviceProvider . stats . resolves ( result ) ;
1214
+ expect ( await collection . totalSize ( ) ) . to . equal ( 1743309443072 ) ;
1215
+ expect ( serviceProvider . stats ) . to . have . been . calledOnceWith ( 'db1' , 'coll1' ) ;
1216
+ } ) ;
1216
1217
} ) ;
1217
1218
1218
1219
describe ( 'drop' , ( ) => {
Original file line number Diff line number Diff line change @@ -1306,7 +1306,7 @@ export default class Collection extends ShellApiWithMongoClass {
1306
1306
async totalSize ( ) : Promise < number > {
1307
1307
this . _emitCollectionApiCall ( 'totalSize' ) ;
1308
1308
const stats = await this . _mongo . _serviceProvider . stats ( this . _database . _name , this . _name , await this . _database . _baseOptions ( ) ) ;
1309
- return ( stats . storageSize || 0 ) + ( stats . totalIndexSize || 0 ) ;
1309
+ return ( Number ( stats . storageSize ) || 0 ) + ( Number ( stats . totalIndexSize ) || 0 ) ;
1310
1310
}
1311
1311
1312
1312
/**
You can’t perform that action at this time.
0 commit comments