Repository navigation
Expand file tree
/
Copy pathtest_commit_write.js
More file actions
68 lines (44 loc) · 1.53 KB
/
Copy pathtest_commit_write.js
File metadata and controls
68 lines (44 loc) · 1.53 KB
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
var testCase = require('nodeunit').testCase,
Repo = require('../lib/git').Repo,
fs = require('fs'),
Commit = require('../lib/git').Commit,
Blob = require('../lib/git').Blob;
var fixture = function(name, trim) {
return trim ? fs.readFileSync("./test/fixtures/" + name, 'ascii').trim() : fs.readFileSync("./test/fixtures/" + name, 'ascii');
}
module.exports = testCase({
setUp: function(callback) {
callback();
},
tearDown: function(callback) {
callback();
},
"Should correctly fetch commit index":function(assert) {
new Repo("./test/grit", {is_bare:true}, function(err, repo) {
repo.git.commit = function() {
var args = Array.prototype.slice.call(arguments, 0);
// Pop the callback
var callback = args.pop();
callback(null, fixture('commit'));
}
repo.commit_index('my message', function(err, results) {
assert.ok(results.indexOf('Created commit') != -1)
assert.done();
})
});
},
"Should correctly commit all":function(assert) {
new Repo("./test/grit", {is_bare:true}, function(err, repo) {
repo.git.commit = function() {
var args = Array.prototype.slice.call(arguments, 0);
// Pop the callback
var callback = args.pop();
callback(null, fixture('commit'));
}
repo.commit_all('my message', function(err, results) {
assert.ok(results.indexOf('Created commit') != -1)
assert.done();
})
});
}
});