Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 05efbc4

Browse filesBrowse files
committed
Start converting tests to Mocha + Istanbul
1 parent 42088c9 commit 05efbc4
Copy full SHA for 05efbc4

File tree

Expand file treeCollapse file tree

9 files changed

+128
-83
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

9 files changed

+128
-83
lines changed
Open diff view settings
Collapse file

‎.gitignore‎

Copy file name to clipboardExpand all lines: .gitignore
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
/node_modules/
22
/vendor/libgit2/
33
/build/
4+
/coverage/
45
/test/repos/
56

67
/vendor/Release
78
/vendor/*.vcxproj
89
/vendor/*.filters
910
/vendor/*.sln
1011

12+
/generate/idefs.json
13+
/binding.gyp
14+
1115
/src/*
1216
!/src/functions/copy.cc
1317
!/src/wrapper.cc
1418

1519
/include/*
1620
!/include/functions/copy.h
1721
!/include/wrapper.h
18-
19-
/generate/idefs.json
20-
/binding.gyp
Collapse file

‎lib/nodegit.js‎

Copy file name to clipboardExpand all lines: lib/nodegit.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ try {
88
rawApi = require("../build/Release/nodegit");
99
}
1010
catch (e) {
11+
/* istanbul ignore next */
1112
rawApi = require("../build/Debug/nodegit");
1213
}
1314

Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@
5252
"promisify-node": "~0.1.2"
5353
},
5454
"devDependencies": {
55-
"jshint": "~2.5.1",
5655
"async": "~0.9.0",
5756
"aws-sdk": "~2.0.0-rc.20",
5857
"ejs": "~1.0.0",
58+
"istanbul": "~0.2.14",
59+
"jshint": "~2.5.1",
60+
"mocha": "~1.20.1",
5961
"nodeunit": "~0.9.0"
6062
},
6163
"binary": {
@@ -64,8 +66,9 @@
6466
"host": "https://s3.amazonaws.com/nodegit/nodegit/"
6567
},
6668
"scripts": {
67-
"lint": "jshint lib test/*.js",
68-
"test": "cd test && nodeunit nodegit.js",
69+
"lint": "jshint lib test/tests/*.js",
70+
"mocha": "istanbul cover _mocha -- test/tests --report=lcov",
71+
"test": "npm run lint && npm run mocha",
6972
"publish": "node-pre-gyp package && node-pre-gyp publish",
7073
"generate": "node generate/setup && node generate",
7174
"install": "npm run generate && node install"
Collapse file

‎test/blob.js‎

Copy file name to clipboardExpand all lines: test/blob.js
-13Lines changed: 0 additions & 13 deletions
This file was deleted.
Collapse file

‎test/commit.js‎

Copy file name to clipboardExpand all lines: test/commit.js
-64Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,4 @@
11
var git = require('../'),
2-
rimraf = require('rimraf'),
3-
fs = require( 'fs' );
4-
5-
var historyCountKnownSHA = 'fce88902e66c72b5b93e75bdb5ae717038b221f6';
6-
7-
exports.message = function(test) {
8-
test.expect(2);
9-
git.Repo.open('repos/workdir/.git', function(error, repository) {
10-
repository.getCommit(historyCountKnownSHA, function(error, commit) {
11-
var message = commit.message();
12-
test.equals(error, null, 'There should be no error');
13-
test.equals(message, 'Update README.md', 'Message should match expected value');
14-
test.done();
15-
});
16-
});
17-
};
18-
19-
exports.sha = function(test) {
20-
test.expect(2);
21-
git.Repo.open('repos/workdir/.git', function(error, repository) {
22-
repository.getCommit(historyCountKnownSHA, function(error, commit) {
23-
var sha = commit.sha();
24-
test.equals(error, null, 'There should be no error');
25-
test.equals(sha, historyCountKnownSHA, 'SHA should match expected value');
26-
test.done();
27-
});
28-
});
29-
};
30-
31-
exports.time = function(test) {
32-
test.expect(2);
33-
git.Repo.open('repos/workdir/.git', function(error, repository) {
34-
repository.getCommit(historyCountKnownSHA, function(error, commit) {
35-
var time = commit.timeMs();
36-
test.equals(error, null, 'There should be no error');
37-
test.equals(time, 1362012884000, 'Time should match expected value');
38-
test.done();
39-
});
40-
});
41-
};
42-
43-
exports.date = function(test) {
44-
test.expect(2);
45-
git.Repo.open('repos/workdir/.git', function(error, repository) {
46-
repository.getCommit(historyCountKnownSHA, function(error, commit) {
47-
var date = commit.date();
48-
test.equals(error, null, 'There should be no error');
49-
test.equals(date.getTime(), 1362012884000, 'Date should match expected value');
50-
test.done();
51-
});
52-
});
53-
};
54-
55-
exports.offset = function(test) {
56-
test.expect(2);
57-
git.Repo.open('repos/workdir/.git', function(error, repository) {
58-
repository.getCommit(historyCountKnownSHA, function(error, commit) {
59-
var offset = commit.offset();
60-
test.equals(error, null, 'There should be no error');
61-
test.equals(offset, 780, 'Offset should match expected value');
62-
test.done();
63-
});
64-
});
65-
};
662

673
exports.author = function(test) {
684
test.expect(2);
Collapse file

‎test/runner.js‎

Copy file name to clipboardExpand all lines: test/runner.js
Whitespace-only changes.
Collapse file

‎test/tests/blob.js‎

Copy file name to clipboard
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var assert = require("assert");
2+
var path = require("path");
3+
4+
var nodegit = require("../../");
5+
6+
describe("Blob", function() {
7+
var reposPath = path.resolve("test/repos/workdir/.git");
8+
9+
var Oid = nodegit.Oid;
10+
var Repository = nodegit.Repository;
11+
12+
it("can fetch content from a commit", function(done) {
13+
var oid= Oid.fromstr("111dd657329797f6165f52f5085f61ac976dcf04");
14+
15+
Repository.open(reposPath, function(err, repository) {
16+
repository.getBlob(oid, function(err, blob) {
17+
var contents = blob.toString();
18+
19+
assert.equal(contents.slice(0, 7), "@import");
20+
21+
done();
22+
});
23+
});
24+
});
25+
});
Collapse file

‎test/tests/commit.js‎

Copy file name to clipboard
+83Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
var assert = require("assert");
2+
var rimraf = require("rimraf");
3+
var path = require("path");
4+
var fs = require( "fs" );
5+
6+
var nodegit = require("../../");
7+
var Repository = nodegit.Repository;
8+
9+
describe("Commit", function() {
10+
var historyCountKnownSHA = "fce88902e66c72b5b93e75bdb5ae717038b221f6";
11+
var reposPath = path.resolve("test/repos/workdir/.git");
12+
13+
var Commit = require("./commit");
14+
15+
describe("when fetched", function() {
16+
17+
it("makes its message available", function(done) {
18+
Repository.open(reposPath, function(error, repository) {
19+
repository.getCommit(historyCountKnownSHA, function(error, commit) {
20+
var message = commit.message();
21+
22+
assert.equal(error, null);
23+
assert.equal(message, "Update README.md");
24+
25+
done();
26+
});
27+
});
28+
});
29+
30+
it("makes its sha available", function(done) {
31+
Repository.open(reposPath, function(error, repository) {
32+
repository.getCommit(historyCountKnownSHA, function(error, commit) {
33+
var sha = commit.sha();
34+
35+
assert.equal(error, null);
36+
assert.equal(sha, historyCountKnownSHA);
37+
38+
done();
39+
});
40+
});
41+
});
42+
43+
it("makes its time available", function(done) {
44+
Repository.open(reposPath, function(error, repository) {
45+
repository.getCommit(historyCountKnownSHA, function(error, commit) {
46+
var time = commit.timeMs();
47+
48+
assert.equal(error, null);
49+
assert.equal(time, 1362012884000);
50+
51+
done();
52+
});
53+
});
54+
});
55+
56+
it("makes its date available", function(done) {
57+
Repository.open(reposPath, function(error, repository) {
58+
repository.getCommit(historyCountKnownSHA, function(error, commit) {
59+
var date = commit.date();
60+
61+
assert.equal(error, null);
62+
assert.equal(date.getTime(), 1362012884000);
63+
64+
done();
65+
});
66+
});
67+
});
68+
69+
it("makes its offset available", function(done) {
70+
Repository.open(reposPath, function(error, repository) {
71+
repository.getCommit(historyCountKnownSHA, function(error, commit) {
72+
var offset = commit.offset();
73+
74+
assert.equal(error, null);
75+
assert.equal(offset, 780);
76+
77+
done();
78+
});
79+
});
80+
});
81+
82+
});
83+
});
Collapse file

‎test/tests/repository.js‎

Copy file name to clipboard
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var assert = require("assert");
2+
var rimraf = require("rimraf");
3+
var path = require("path");
4+
var fs = require( "fs" );
5+
6+
var nodegit = require("../../");
7+
8+
describe("Repository", function() {
9+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.