Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beforeEach(function (done) {
this.mount = 'derp';
this.remote = 'http://localhost:5984/quilt_test';
this.config_path = './derp_config.json';
async.series([
// create the local folder
fs.mkdir.bind(fs, this.mount),
// create the remote db
request.bind(request, {
method: 'PUT',
url: this.remote
}),
// put a doc into the remote
request.bind(request, {
method: 'POST',
url: this.remote,
json: {
_id: 'test.md',
hash: 'whatever man just whatever',
_attachments: {
file: {
content_type: 'text/plain',
data: new Buffer('# hello world').toString('base64')
}
}
}
})
], done);
});
it('should delete a doc', function (done) {
var self = this;
async.series([
request.bind(request, {
url: this.remote,
method: 'POST',
json: {
_id: 'test.md',
hash: 'blow me up!'
}
}),
quilter.push.destroy.bind(this, 'test.md'),
request.get.bind(request, [this.remote, 'test.md'].join('/'))
], function (err, res) {
assert(!err);
var status_code = res[2][0].statusCode;
assert.equal(status_code, 404);
done();
});
});
beforeEach(function (done) {
async.parallel([
fs.writeFile.bind(fs, this.quilt.util.file.path('other.md'), '# hello world'),
request.bind(request, {
method: 'POST',
url: this.remote,
json: {
_id: 'test.md',
hash: 'whatever man just whatever',
_attachments: {
file: {
content_type: 'text/plain',
data: new Buffer('# good bye').toString('base64')
}
}
}
})
], done);
});
afterEach(function (done) {
async.series([
request.bind(request, {
url: this.remote,
method: 'DELETE'
}),
quilter.util.rmdir.bind(null, this.mount)
], function (err) {
done(err);
});
});
});
before(function (done) {
this.remote = 'http://localhost:5984/quilt_test';
this.mount = './derp';
this.doc_id = 'test.md';
async.parallel([
async.series.bind(async, [
fs.mkdir.bind(fs, this.mount),
fs.writeFile.bind(fs, path.join(this.mount, this.doc_id), '# hello world')
]),
request.bind(request, {
url: this.remote,
method: 'PUT'
})
], done);
});
afterEach(function (done) {
async.series([
request.bind(request, {
url: this.remote,
method: 'DELETE'
}),
quilter.util.rmdir.bind(null, this.mount)
], done);
});
});