support arbitrary test repo length + add tags to the test repo

This commit is contained in:
oleg 2015-06-28 11:39:34 +03:00
parent 83564f7091
commit b5bca8076d
20 changed files with 48 additions and 33 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
node_modules
test/workspace
test/distributor/workspace
test/repos/mercurial/.hg/strip-backup
static/css/**/*.css
static/fonts
static/js/libs

View File

@ -69,8 +69,9 @@ describe('Distributor run self after catch', function() {
itRunWithRev(1, 1);
itRunWithRev(2, 2);
it('should call run 3 times in total', function() {
expect(executorRunSpy.callCount).equal(3);
var revsCount = helpers.mercurialRevs.length;
it('should call run ' + revsCount + ' times in total', function() {
expect(executorRunSpy.callCount).equal(revsCount);
});
});

View File

@ -55,13 +55,16 @@ var expect = require('expect.js'),
});
});
it('scm data should be rev: 2, changes: [0-2], latest', function() {
expect(scmData).eql({
rev: mercurialRevs[2],
changes: mercurialRevs.slice().reverse(),
isLatest: true
});
});
it(
'scm data should be rev: last, changes: [0-last], is latest',
function() {
expect(scmData).eql({
rev: mercurialRevs[mercurialRevs.length - 1],
changes: mercurialRevs.slice().reverse(),
isLatest: true
});
}
);
});
describe('with scm rev default and catch rev "first revision"', function() {
@ -98,13 +101,17 @@ var expect = require('expect.js'),
executor.run({}, done);
});
it('scm data should be rev: 2, changes: [2], latest', function() {
expect(scmData).eql({
rev: mercurialRevs[2],
changes: mercurialRevs.slice(2, 3).reverse(),
isLatest: true
});
});
it(
'scm data should be rev: last, changes: [2-last], is latest',
function() {
expect(scmData).eql({
rev: mercurialRevs[mercurialRevs.length - 1],
changes: mercurialRevs.slice(2).reverse(),
isLatest: true
});
}
);
});
});

View File

@ -34,4 +34,9 @@ exports.mercurialRevs = [{
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'
}];

View File

@ -1,2 +1,2 @@
9d7d08445f4ce095c22a98a902a391973cf07f37 2
9d7d08445f4ce095c22a98a902a391973cf07f37 default
2ff4bec8b4ccc89af0bcabc0710713573078ebdb 3
2ff4bec8b4ccc89af0bcabc0710713573078ebdb default

View File

@ -1,2 +1,5 @@
2 9d7d08445f4ce095c22a98a902a391973cf07f37
3 2ff4bec8b4ccc89af0bcabc0710713573078ebdb 8354ec217ac72171221f831e40a640e499e0f246
da2762e71e87935198a25b0fceab0a364ad2e6d7 zero revision
9d7d08445f4ce095c22a98a902a391973cf07f37 second revision
9d7d08445f4ce095c22a98a902a391973cf07f37 release 0.1.0

Binary file not shown.

View File

@ -1 +1 @@
third revision
temporary amend commit for 6e9e54ed42ff

Binary file not shown.

View File

@ -1,3 +1,4 @@
data/.hgtags.i
data/rev0.txt.i
data/rev1.txt.i
data/rev2.txt.i

Binary file not shown.

View File

@ -1 +0,0 @@
1 da2762e71e87935198a25b0fceab0a364ad2e6d7

View File

@ -1 +0,0 @@
default

View File

@ -1,2 +0,0 @@
2
commit

View File

@ -0,0 +1,3 @@
da2762e71e87935198a25b0fceab0a364ad2e6d7 zero revision
9d7d08445f4ce095c22a98a902a391973cf07f37 second revision
9d7d08445f4ce095c22a98a902a391973cf07f37 release 0.1.0

View File

@ -75,26 +75,25 @@ var expect = require('expect.js'),
scm.pull(scm.defaultRev, done);
});
it('now (after pull) expect rev1 and rev2 as new changes (in reverse ' +
it('now (after pull) expect all after rev 0 as new changes (in reverse ' +
'order) from rev0 to default revision', function(done) {
scm.getChanges(data[0].id, scm.defaultRev, function(err, changes) {
if (err) return done(err);
expect(changes).ok();
expect(changes).length(2);
expect(changes).eql([data[2], data[1]]);
expect(changes).eql(data.slice(1).reverse());
done();
});
});
it('update to default revision (should update to rev2) without error',
it('update to default revision (should update to last) without error',
function(done) {
scm.update(scm.defaultRev, done);
});
it('expect current revision equals to rev2', function(done) {
it('expect current revision equals to last', function(done) {
scm.getCurrent(function(err, rev) {
if (err) return done(err);
expect(rev).eql(data[2]);
expect(rev).eql(data[data.length - 1]);
done();
});
});
@ -104,12 +103,11 @@ var expect = require('expect.js'),
});
it('expect repository log from rev0 to default revision equals to ' +
'rev1 and rev2 (in reverse order)', function(done) {
'all revs followed by rev 0 (in reverse order)', function(done) {
scm.getChanges(data[0].id, scm.defaultRev, function(err, changes) {
if (err) return done(err);
expect(changes).ok();
expect(changes).length(2);
expect(changes).eql([data[2], data[1]]);
expect(changes).eql(data.slice(1).reverse());
done();
});
});