nci/test/helpers.js

73 lines
1.8 KiB
JavaScript
Raw Normal View History

2015-06-23 19:18:13 +00:00
'use strict';
var SpawnCommand = require('../lib/command/spawn').Command,
2015-06-29 18:57:34 +00:00
fs = require('fs'),
db = require('../db');
exports.removeDir = function(dir, callback) {
new SpawnCommand().run({cmd: 'rm', args: ['-R', dir]}, callback);
};
exports.removeDirIfExists = function(dir, done) {
if (fs.exists(dir, function(isExists) {
if (isExists) {
exports.removeDir(dir, done);
} else {
done();
}
}));
};
2015-06-23 19:18:13 +00:00
// revisions for the test mercurial repo
exports.mercurialRevs = [{
id: 'da2762e71e87',
2015-06-28 10:04:36 +00:00
tags: ['zero revision'],
2015-06-23 19:18:13 +00:00
author: 'kotbegemot',
date: new Date('Fri May 09 22:36:41 2014 +0400').getTime(),
comment: 'zero revision'
}, {
id: '98e3a18d8193',
author: 'kotbegemot',
date: new Date('Fri May 09 22:37:19 2014 +0400').getTime(),
comment: 'first revision'
}, {
id: '9d7d08445f4c',
2015-06-28 10:04:36 +00:00
tags: ['release 0.1.0', 'second revision'],
2015-06-23 19:18:13 +00:00
author: 'kotbegemot',
date: new Date('Sat May 10 03:18:20 2014 +0400').getTime(),
comment: 'third revision'
}, {
id: '2ff4bec8b4cc',
author: 'okv',
date: new Date('Sun Jun 28 10:54:22 2015 +0300').getTime(),
comment: 'add tags'
2015-06-23 19:18:13 +00:00
}];
2015-06-29 18:57:34 +00:00
2015-07-13 21:20:30 +00:00
exports.gitRevs = [{
id: '4ec4643d2044871177d758b3b0e7962b5c4f40d1',
tags: ['zero'],
author: 'oleg',
date: new Date('Mon Jul 13 22:30:58 2015 +0300').getTime(),
comment: 'zero revision'
}, {
id: 'f76bae67efc6fd5a43392517646bb9d685f4266f',
author: 'oleg',
date: new Date('Mon Jul 13 22:31:58 2015 +0300').getTime(),
comment: 'first revision'
}, {
id: '39245d9b93bcd2a0c6708d483b83c98a7bff1d3e',
tags: ['release-0.1.0', 'second-revision'],
author: 'oleg',
date: new Date('Mon Jul 13 22:32:59 2015 +0300').getTime(),
comment: 'third revision'
}];
2015-06-29 18:57:34 +00:00
exports.initDb = function(callback) {
db.init('path/to/db/ignored/for/memdown', {
db: require('memdown'),
valueEncoding: 'json'
}, callback);
return db;
};