Skip to content

Commit b202294

Browse files
committed
add a test for the recordsPerType option
1 parent 1ca92ff commit b202294

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/integration/adapters/memory.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ var MemoryAdapter = memoryAdapter(Adapter)
2121
var adapter = new MemoryAdapter({
2222
keys: keys,
2323
errors: errors,
24-
recordTypes: recordTypes
24+
recordTypes: recordTypes,
25+
options: {
26+
recordsPerType: 20
27+
}
2528
})
2629

2730
testAdapter(memoryAdapter)
@@ -83,6 +86,23 @@ run(function (assert, comment) {
8386
})
8487

8588

89+
run(function (assert, comment) {
90+
comment('manual memory management')
91+
return adapter.connect()
92+
.then(function () {
93+
var records = []
94+
for (var i = 0; i < 100; i++) {
95+
records.push({ int: i })
96+
}
97+
return adapter.create('type', records)
98+
})
99+
.then(function (records) {
100+
assert(records.length === 100, 'records created')
101+
assert(Object.keys(adapter.db.type).length === 20, 'only max records retained')
102+
})
103+
})
104+
105+
86106
function Integer (x) { return (x | 0) === x }
87107
Integer.prototype = new Number()
88108
Integer.compare = function (a, b) { return a - b }

0 commit comments

Comments
 (0)