-
Notifications
You must be signed in to change notification settings - Fork 12
/
git_scenario.mocha.js
146 lines (120 loc) · 3.53 KB
/
git_scenario.mocha.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
var should = require('should');
var shell = require('shelljs');
var vizion = require('..');
var p = require('path');
if (shell.which('git') !== null) {
describe('Git scenario', function() {
var repo_pwd = '';
var tmp_meta = {};
before(function(done) {
this.timeout(10000);
shell.cd('test/fixtures');
if (shell.ls('angular-bridge').length == 0)
shell.exec('git clone https://github.com/Unitech/angular-bridge.git');
repo_pwd = p.join(shell.pwd(), 'angular-bridge');
done();
});
after(function(done) {
shell.rm('-rf', 'angular-bridge');
done();
});
it('should update to latest', function(done) {
this.timeout(10000);
vizion.update({
folder : repo_pwd
}, function(err, meta) {
should(err).not.exist;
should(meta.success).be.false;
done();
});
});
it('should analyze versioned folder', function(done) {
this.timeout(10000);
vizion.analyze({
folder: repo_pwd
}, function(err, meta) {
should(err).not.exist;
meta.type.should.equal('git');
meta.branch.should.equal('master');
should(meta.branch_exists_on_remote).be.true
should.exist(meta.comment);
should.exist(meta.url);
should.exist(meta.revision);
should(meta.next_rev).be.null;
should(meta.prev_rev).not.be.null;
tmp_meta = meta;
done();
});
});
it('should checkout older version', function(done) {
this.timeout(10000);
vizion.revertTo({
folder : repo_pwd,
revision : tmp_meta.prev_rev
}, function(err, meta) {
should(err).not.exist;
done();
});
});
it('should has next and prev', function(done) {
this.timeout(10000);
vizion.analyze({
folder: repo_pwd
}, function(err, meta) {
should(err).not.exist;
should(meta.next_rev).not.be.null;
should(meta.prev_rev).not.be.null;
tmp_meta = meta;
done();
});
});
it('should see that its not on HEAD', function(done) {
this.timeout(10000);
vizion.isUpToDate({
folder : repo_pwd
}, function(err, meta) {
should(err).not.exist;
meta.is_up_to_date.should.be.false;
done();
});
});
it('should recursively downgrade to first commit', function(done) {
this.timeout(20000);
var callback = function(err, meta) {
should(err).not.exist;
should(meta).be.ok;
if (meta.success === true) {
vizion.prev({folder: repo_pwd}, callback);
}
else {
should(meta.success).be.false;
vizion.analyze({folder: repo_pwd}, function(err, meta) {
should(err).not.exist;
should(meta.prev_rev).be.null;
done();
});
}
}
vizion.prev({folder : repo_pwd}, callback);
});
it('should recursively upgrade to most recent commit', function(done) {
this.timeout(20000);
var callback = function(err, meta) {
should(err).not.exist;
should(meta).be.ok;
if (meta.success === true) {
vizion.next({folder: repo_pwd}, callback);
}
else {
should(meta.success).be.false;
vizion.analyze({folder: repo_pwd}, function(err, meta) {
should(err).not.exist;
should(meta.next_rev).be.null;
done();
});
}
}
vizion.next({folder : repo_pwd}, callback);
});
});
}