-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: issue with lower fill factor than order for single element tree (#…
…14) * fix: issue with lower fill factor than order for single element tree (#13) * fix(SBFRoot/findLowerThan): finding document on equal case for lte Specific case when order is bigger than actual size * style: formatting * test: add tests for tree with lower size than order Co-authored-by: Anurag Vohra <53807480+anuragvohraec@users.noreply.github.com>
- Loading branch information
1 parent
1bd6f95
commit 4924272
Showing
2 changed files
with
70 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const {expect} = require('chai'); | ||
const {SBTree} = require('../..'); | ||
const users = require('./users'); | ||
|
||
const toNames = (arr)=>{ | ||
return arr.reduce((acc, el)=>{ | ||
acc.push(el.name); | ||
return acc | ||
},[]); | ||
} | ||
describe('E2E - UseCase with lower fill factor than order', function suite() { | ||
let ts = 1588913801357; | ||
describe('RegUser DB', async () => { | ||
const customTree = new SBTree({order:40}); | ||
const doc = { | ||
_id: '754aeea7c0919797d6eb2710d200eafd', | ||
key: 'VATEmq', | ||
value: 4, | ||
ts | ||
}; | ||
|
||
it('should insert', async function () { | ||
await customTree.insertDocuments(doc); | ||
}); | ||
it('should get document', async function () { | ||
const res = await customTree.getDocument('754aeea7c0919797d6eb2710d200eafd') | ||
expect(res).to.deep.equal(doc); | ||
}); | ||
it('should be able to search the document', async function () { | ||
const found = await customTree.findDocuments({ts}); | ||
expect(found).to.deep.equal([doc]); | ||
|
||
const foundLowerThanEq = await customTree.findDocuments({ts:{$lte: ts}}); | ||
expect(foundLowerThanEq).to.deep.equal([doc]); | ||
|
||
const foundLowerThanEq1 = await customTree.findDocuments({ts:{$lte: ts+1000}}); | ||
expect(foundLowerThanEq1).to.deep.equal([doc]); | ||
|
||
const foundGreaterThanEq = await customTree.findDocuments({ts:{$gte: ts}}); | ||
expect(foundGreaterThanEq).to.deep.equal([doc]); | ||
|
||
const foundGreaterThanEq1 = await customTree.findDocuments({ts:{$gte: ts-1000}}); | ||
expect(foundGreaterThanEq1).to.deep.equal([doc]); | ||
|
||
const foundEq = await customTree.findDocuments({ts:{$eq: ts}}); | ||
expect(foundEq).to.deep.equal([doc]); | ||
}); | ||
it('should be able to delete the document', async function () { | ||
const deleted = await customTree.deleteDocuments({ts: {$lte: ts+1}}); | ||
expect(deleted).to.deep.equal([doc]); | ||
|
||
const found = await customTree.findDocuments({ts}); | ||
expect(found).to.deep.equal([]); | ||
|
||
const res = await customTree.getDocument('754aeea7c0919797d6eb2710d200eafd') | ||
expect(res).to.deep.equal({}); | ||
}); | ||
}); | ||
}) |