Skip to content

Commit

Permalink
add a test for the recordsPerType option
Browse files Browse the repository at this point in the history
  • Loading branch information
gr0uch committed Aug 23, 2021
1 parent 1ca92ff commit b202294
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion test/integration/adapters/memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ var MemoryAdapter = memoryAdapter(Adapter)
var adapter = new MemoryAdapter({
keys: keys,
errors: errors,
recordTypes: recordTypes
recordTypes: recordTypes,
options: {
recordsPerType: 20
}
})

testAdapter(memoryAdapter)
Expand Down Expand Up @@ -83,6 +86,23 @@ run(function (assert, comment) {
})


run(function (assert, comment) {
comment('manual memory management')
return adapter.connect()
.then(function () {
var records = []
for (var i = 0; i < 100; i++) {
records.push({ int: i })
}
return adapter.create('type', records)
})
.then(function (records) {
assert(records.length === 100, 'records created')
assert(Object.keys(adapter.db.type).length === 20, 'only max records retained')
})
})


function Integer (x) { return (x | 0) === x }
Integer.prototype = new Number()
Integer.compare = function (a, b) { return a - b }

0 comments on commit b202294

Please sign in to comment.