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
Merged
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 18 additions & 11 deletions 29 test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,34 @@ var promisify = require("promisify-node");
var fs = promisify("fs");

// Have to wrap exec, since it has a weird callback signature.
var exec = promisify(function(command, callback) {
return require("child_process").exec(command, callback);
var exec = promisify(function(command, opts, callback) {
return require("child_process").exec(command, opts, callback);
});

before(function(done) {
this.timeout(150000);

var url = "https://github.com/nodegit/nodegit";
var url = "https://github.com/nodegit/test";
var done = done.bind(null, null);

fs.exists("test/repos").then(function() {
return fs.mkdir("test/repos").then(function() {
return exec("git init test/repos/empty");
}).then(function() {
function initEmpty() {
return exec("git init test/repos/empty");
}

fs.mkdir("test/repos").then(initEmpty, initEmpty)
.then(function() {
return exec("git clone " + url + " test/repos/workdir");
}).then(function() {
return exec("git checkout rev-walk", {cwd: "test/repos/workdir"})
}).then(function() {
return exec("git checkout master", {cwd: "test/repos/workdir"})
}).then(function() {
var nonrepo = "test/repos/nonrepo";

return fs.mkdir(nonrepo).then(function() {
function writeBogus() {
return fs.writeFile(nonrepo + "/file.txt", "This is a bogus file");
});
})
}).then(done, done);
}

return fs.mkdir(nonrepo).then(writeBogus, writeBogus);
}).then(done, done);
});
8 changes: 4 additions & 4 deletions 8 test/tests/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Remote", function() {
it("can read the remote url", function() {
assert.equal(
this.remote.url().replace(".git", ""),
"https://github.com/nodegit/nodegit");
"https://github.com/nodegit/test");
});

it("can read the remote name", function() {
Expand All @@ -41,18 +41,18 @@ describe("Remote", function() {

it("can create a new remote", function() {
var repository = this.repository;
var url = "https://github.com/nodegit/nodegit";
var url = "https://github.com/nodegit/test";

return Remote.create(repository, "origin2", url).then(function() {
return Remote.load(repository, "origin2").then(function(remote) {
assert(remote.url(), "https://github.com/nodegit/nodegit");
assert(remote.url(), "https://github.com/nodegit/test");
});
});
});

it("can delete a remote", function() {
var repository = this.repository;
var url = "https://github.com/nodegit/nodegit";
var url = "https://github.com/nodegit/test";

return Remote.create(repository, "origin3", url).then(function() {
return Remote.load(repository, "origin3").then(function(remote) {
Expand Down
53 changes: 38 additions & 15 deletions 53 test/tests/revwalk.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,75 @@ describe("Revwalk", function() {
var Revwalk = require("../../lib/revwalk");
var Oid = require("../../lib/oid");

before(function() {
before(function(done) {
var test = this;

return Repository.open(reposPath).then(function(repository) {
test.repository = repository;
test.walker = repository.createRevWalk();

return test.repository.getMaster().then(function(master) {
test.master = master;
test.walker.push(test.master.id());
return test.repository.getBranch("rev-walk").then(function(branch) {
test.branch = branch;
done();
});
});
});

beforeEach(function() {
this.walker = this.repository.createRevWalk();
this.walker.push(this.branch.id());
});

it("can create a walker", function() {
assert.ok(this.walker instanceof Revwalk);
});

it("can push an object", function() {
var sha = this.master.sha();
var sha = this.branch.sha();

return this.walker.next().then(function(commit) {
assert.equal(sha, commit);
});
});

it.skip("can hide an object", function() {
it("can hide an object", function() {
var test = this;

this.walker.hide(Oid.fromstr("a03e044fcb45c654d4e15a4e495a6a0c6e632854"));

return test.walker.next().then(function(commit) {
return test.walker.next().then(function(commit) {
assert.equal(commit, "1efa3354299ede235f90880383176fb5d48aaa89");
return test.walker.next().then(function(commit) {
return test.walker.next().then(function(commit) {
assert.equal(commit.toString(),
"b8a94aefb22d0534cc0e5acf533989c13d8725dc");
test.walker = test.repository.createRevWalk();
test.walker.push(test.branch.id());
test.walker.hide(
Oid.fromstr("b8a94aefb22d0534cc0e5acf533989c13d8725dc"));

return test.walker.next().then(function(commit) {
return test.walker.next().then(function(commit) {
return test.walker.next().then(function(commit) {
assert.equal(commit.toString(),
"95f695136203a372751c19b6353aeb5ae32ea40e");
return test.walker.next().then(function(commit) {
assert.equal(commit, undefined);
});
});
});
});
});
});
});
});
});

it.skip("can simplify to first parent", function() {
it("can simplify to first parent", function() {
var test = this;

test.walker.simplifyFirstParent();

return test.walker.next().then(function(commit) {
return test.walker.next().then(function(commit) {
assert.equal(commit, "231c550f3ec28874b4c426fc9eebad9a742e1332");
return test.walker.next().then(function(commit) {
assert.equal(commit.toString(),
"b8a94aefb22d0534cc0e5acf533989c13d8725dc");
});
});
});
});
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.