This commit is contained in:
2026-05-13 19:58:16 +03:00
commit f5adeb292b
78 changed files with 12024 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
//
// Implements a fake db for testing
//
class FakeDB {
//
// Constructor
//
constructor(data) {
this.data = data
this.fetch = this.fetch.bind(this)
this.pipe = this.pipe.bind(this)
}
//
// Simulate a db connection by just returning
// a promise
//
connect() {
return Promise.resolve()
}
//
// Returns all results in one batch
//
fetch() {
return Promise.resolve({
recordset: this.data
})
}
//
// Delivers results to the specified write
// stream
//
pipe(query, writable) {
this.data.forEach(function(record) {
writable.write(record)
})
writable.end()
return writable
}
}
//
// Export the class
//
module.exports = FakeDB