Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Start converting tests to Mocha + Istanbul
  • Loading branch information
tbranyen committed Jul 11, 2014
commit 05efbc488dbee94dd908e18c48ba1838cf059d95
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/node_modules/
/vendor/libgit2/
/build/
/coverage/
/test/repos/

/vendor/Release
/vendor/*.vcxproj
/vendor/*.filters
/vendor/*.sln

/generate/idefs.json
/binding.gyp

/src/*
!/src/functions/copy.cc
!/src/wrapper.cc

/include/*
!/include/functions/copy.h
!/include/wrapper.h

/generate/idefs.json
/binding.gyp
1 change: 1 addition & 0 deletions lib/nodegit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ try {
rawApi = require("../build/Release/nodegit");
}
catch (e) {
/* istanbul ignore next */
rawApi = require("../build/Debug/nodegit");
}

Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@
"promisify-node": "~0.1.2"
},
"devDependencies": {
"jshint": "~2.5.1",
"async": "~0.9.0",
"aws-sdk": "~2.0.0-rc.20",
"ejs": "~1.0.0",
"istanbul": "~0.2.14",
"jshint": "~2.5.1",
"mocha": "~1.20.1",
"nodeunit": "~0.9.0"
},
"binary": {
Expand All @@ -64,8 +66,9 @@
"host": "https://s3.amazonaws.com/nodegit/nodegit/"
},
"scripts": {
"lint": "jshint lib test/*.js",
"test": "cd test && nodeunit nodegit.js",
"lint": "jshint lib test/tests/*.js",
"mocha": "istanbul cover _mocha -- test/tests --report=lcov",
"test": "npm run lint && npm run mocha",
"publish": "node-pre-gyp package && node-pre-gyp publish",
"generate": "node generate/setup && node generate",
"install": "npm run generate && node install"
Expand Down
13 changes: 0 additions & 13 deletions test/blob.js

This file was deleted.

64 changes: 0 additions & 64 deletions test/commit.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,4 @@
var git = require('../'),
rimraf = require('rimraf'),
fs = require( 'fs' );

var historyCountKnownSHA = 'fce88902e66c72b5b93e75bdb5ae717038b221f6';

exports.message = function(test) {
test.expect(2);
git.Repo.open('repos/workdir/.git', function(error, repository) {
repository.getCommit(historyCountKnownSHA, function(error, commit) {
var message = commit.message();
test.equals(error, null, 'There should be no error');
test.equals(message, 'Update README.md', 'Message should match expected value');
test.done();
});
});
};

exports.sha = function(test) {
test.expect(2);
git.Repo.open('repos/workdir/.git', function(error, repository) {
repository.getCommit(historyCountKnownSHA, function(error, commit) {
var sha = commit.sha();
test.equals(error, null, 'There should be no error');
test.equals(sha, historyCountKnownSHA, 'SHA should match expected value');
test.done();
});
});
};

exports.time = function(test) {
test.expect(2);
git.Repo.open('repos/workdir/.git', function(error, repository) {
repository.getCommit(historyCountKnownSHA, function(error, commit) {
var time = commit.timeMs();
test.equals(error, null, 'There should be no error');
test.equals(time, 1362012884000, 'Time should match expected value');
test.done();
});
});
};

exports.date = function(test) {
test.expect(2);
git.Repo.open('repos/workdir/.git', function(error, repository) {
repository.getCommit(historyCountKnownSHA, function(error, commit) {
var date = commit.date();
test.equals(error, null, 'There should be no error');
test.equals(date.getTime(), 1362012884000, 'Date should match expected value');
test.done();
});
});
};

exports.offset = function(test) {
test.expect(2);
git.Repo.open('repos/workdir/.git', function(error, repository) {
repository.getCommit(historyCountKnownSHA, function(error, commit) {
var offset = commit.offset();
test.equals(error, null, 'There should be no error');
test.equals(offset, 780, 'Offset should match expected value');
test.done();
});
});
};

exports.author = function(test) {
test.expect(2);
Expand Down
Empty file added test/runner.js
Empty file.
25 changes: 25 additions & 0 deletions test/tests/blob.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var assert = require("assert");
var path = require("path");

var nodegit = require("../../");

describe("Blob", function() {
var reposPath = path.resolve("test/repos/workdir/.git");

var Oid = nodegit.Oid;
var Repository = nodegit.Repository;

it("can fetch content from a commit", function(done) {
var oid= Oid.fromstr("111dd657329797f6165f52f5085f61ac976dcf04");

Repository.open(reposPath, function(err, repository) {
repository.getBlob(oid, function(err, blob) {
var contents = blob.toString();

assert.equal(contents.slice(0, 7), "@import");

done();
});
});
});
});
83 changes: 83 additions & 0 deletions test/tests/commit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
var assert = require("assert");
var rimraf = require("rimraf");
var path = require("path");
var fs = require( "fs" );

var nodegit = require("../../");
var Repository = nodegit.Repository;

describe("Commit", function() {
var historyCountKnownSHA = "fce88902e66c72b5b93e75bdb5ae717038b221f6";
var reposPath = path.resolve("test/repos/workdir/.git");

var Commit = require("./commit");

describe("when fetched", function() {

it("makes its message available", function(done) {
Repository.open(reposPath, function(error, repository) {
repository.getCommit(historyCountKnownSHA, function(error, commit) {
var message = commit.message();

assert.equal(error, null);
assert.equal(message, "Update README.md");

done();
});
});
});

it("makes its sha available", function(done) {
Repository.open(reposPath, function(error, repository) {
repository.getCommit(historyCountKnownSHA, function(error, commit) {
var sha = commit.sha();

assert.equal(error, null);
assert.equal(sha, historyCountKnownSHA);

done();
});
});
});

it("makes its time available", function(done) {
Repository.open(reposPath, function(error, repository) {
repository.getCommit(historyCountKnownSHA, function(error, commit) {
var time = commit.timeMs();

assert.equal(error, null);
assert.equal(time, 1362012884000);

done();
});
});
});

it("makes its date available", function(done) {
Repository.open(reposPath, function(error, repository) {
repository.getCommit(historyCountKnownSHA, function(error, commit) {
var date = commit.date();

assert.equal(error, null);
assert.equal(date.getTime(), 1362012884000);

done();
});
});
});

it("makes its offset available", function(done) {
Repository.open(reposPath, function(error, repository) {
repository.getCommit(historyCountKnownSHA, function(error, commit) {
var offset = commit.offset();

assert.equal(error, null);
assert.equal(offset, 780);

done();
});
});
});

});
});
9 changes: 9 additions & 0 deletions test/tests/repository.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var assert = require("assert");
var rimraf = require("rimraf");
var path = require("path");
var fs = require( "fs" );

var nodegit = require("../../");

describe("Repository", function() {
});