add async support to database.query()

This commit is contained in:
Girish Ramakrishnan
2021-05-02 21:12:38 -07:00
parent 199eda82d1
commit 035f356dff
4 changed files with 45 additions and 93 deletions

View File

@@ -10,7 +10,7 @@ var appdb = require('../appdb.js'),
async = require('async'),
backupdb = require('../backupdb.js'),
backups = require('../backups.js'),
blobdb = require('../blobdb.js'),
blobs = require('../blobs.js'),
BoxError = require('../boxerror.js'),
database = require('../database'),
domaindb = require('../domaindb'),
@@ -1329,33 +1329,24 @@ describe('database', function () {
});
describe('blobs', function () {
it('can set value', function (done) {
blobdb.set('someid', Buffer.from('somevalue'), function (error) {
expect(error).to.be(null);
done();
});
it('can set value', async function () {
await blobs.set('someid', Buffer.from('somevalue'));
});
it('can get the set value', function (done) {
blobdb.get('someid', function (error, value) {
expect(error).to.be(null);
expect(value).to.eql(Buffer.from('somevalue'));
done();
});
it('can get the set value', async function () {
const value = await blobs.get('someid');
expect(value).to.eql(Buffer.from('somevalue'));
});
it('can update a value', function (done) {
blobdb.set('someid', Buffer.from('someothervalue'), function (error) {
expect(error).to.be(null);
done();
});
it('can update a value', async function () {
await blobs.set('someid', Buffer.from('someothervalue'));
});
it('can get updated value', function (done) {
blobdb.get('someid', function (error, value) {
expect(error).to.be(null);
expect(value).to.eql(Buffer.from('someothervalue'));
done();
});
it('can get updated value', async function () {
const value = await blobs.get('someid');
expect(value).to.eql(Buffer.from('someothervalue'));
});
it('cannot get randome value', async function () {
const value = await blobs.get('unknownid');
expect(value).to.be(null);
});
});
describe('backup', function () {