Files
adopt-a-street/node_modules/memory-pager/test.js
William Valentin 5aca521c52 feat: Complete CouchDB migration and Docker configuration
- Add comprehensive CouchDB setup and configuration
- Update Docker files for CouchDB compatibility
- Create Kubernetes manifests for CouchDB deployment
- Add migration scripts and documentation
- Update seeding scripts to support both CouchDB and MongoDB
- Add docker-compose for local development
- Create comprehensive setup and deployment guides

🤖 Generated with [AI Assistant]

Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
2025-11-01 13:32:39 -07:00

81 lines
1.4 KiB
JavaScript

var tape = require('tape')
var pager = require('./')
tape('get page', function (t) {
var pages = pager(1024)
var page = pages.get(0)
t.same(page.offset, 0)
t.same(page.buffer, Buffer.alloc(1024))
t.end()
})
tape('get page twice', function (t) {
var pages = pager(1024)
t.same(pages.length, 0)
var page = pages.get(0)
t.same(page.offset, 0)
t.same(page.buffer, Buffer.alloc(1024))
t.same(pages.length, 1)
var other = pages.get(0)
t.same(other, page)
t.end()
})
tape('get no mutable page', function (t) {
var pages = pager(1024)
t.ok(!pages.get(141, true))
t.ok(pages.get(141))
t.ok(pages.get(141, true))
t.end()
})
tape('get far out page', function (t) {
var pages = pager(1024)
var page = pages.get(1000000)
t.same(page.offset, 1000000 * 1024)
t.same(page.buffer, Buffer.alloc(1024))
t.same(pages.length, 1000000 + 1)
var other = pages.get(1)
t.same(other.offset, 1024)
t.same(other.buffer, Buffer.alloc(1024))
t.same(pages.length, 1000000 + 1)
t.ok(other !== page)
t.end()
})
tape('updates', function (t) {
var pages = pager(1024)
t.same(pages.lastUpdate(), null)
var page = pages.get(10)
page.buffer[42] = 1
pages.updated(page)
t.same(pages.lastUpdate(), page)
t.same(pages.lastUpdate(), null)
page.buffer[42] = 2
pages.updated(page)
pages.updated(page)
t.same(pages.lastUpdate(), page)
t.same(pages.lastUpdate(), null)
t.end()
})