diff --git a/test/tests/index.js b/test/tests/index.js index f3d29e7f7..9c5c794eb 100644 --- a/test/tests/index.js +++ b/test/tests/index.js @@ -29,6 +29,17 @@ describe("Index", function() { this.index.clear(); }); + // THIS TEST DOES NOT MAKE IT FAIL + it.skip("can remove repo's folder after accessing its index", function() { + var entries = this.index.entries(); + + assert.equal(entries[0].path, ".gitignore"); + return fse.remove(reposPath) + .then(function() { + assert.equal(false, fse.existsSync(reposPath)); + }); + }); + it("can get the index of a repo and examine entries", function() { var entries = this.index.entries(); diff --git a/test/tests/submodule.js b/test/tests/submodule.js index 2323fa56c..d500d52e2 100644 --- a/test/tests/submodule.js +++ b/test/tests/submodule.js @@ -1,5 +1,6 @@ var assert = require("assert"); var path = require("path"); +var fse = require("fs-extra"); var local = path.join.bind(path, __dirname); describe("Submodule", function() { @@ -158,6 +159,130 @@ describe("Submodule", function() { }); }); + // THIS TEST MAKES IT FAIL + it.skip("make remove repo fail 01", function() { + this.timeout(30000); + + var repo = this.repository; + var submodulePath = "nodegittest"; + var submoduleUrl = "https://github.com/nodegit/test.git"; + + var submodule; + var submoduleRepo; + + return NodeGit.Submodule.addSetup(repo, submoduleUrl, submodulePath, 0) + .then(function(_submodule) { + submodule = _submodule; + + return submodule.init(0); + }) + .then(function() { + return submodule.open(); + }) + .then(function(_submoduleRepo) { + submoduleRepo = _submoduleRepo; + return submoduleRepo.fetch("origin", null, null); + }) + .then(function() { + return submoduleRepo.getReference("origin/master"); + }) + .then(function(reference) { + return reference.peel(NodeGit.Object.TYPE.COMMIT); + }) + .then(function(commit) { + return submoduleRepo.createBranch("master", commit.id()); + }) + .then(function() { + return submodule.addFinalize(); + }) + .then(function() { + // check whether the submodule exists + return Submodule.lookup(repo, submodulePath); + }) + .then(function(submodule) { + assert.equal(submodule.name(), submodulePath); + // check whether .gitmodules and the submodule are in the index + return repo.refreshIndex(); + }) + .then(function(index) { + var entries = index.entries(); + assert.equal(entries.length, 2); + assert.equal(entries[0].path, ".gitmodules"); + assert.equal(entries[1].path, submodulePath); + return fse.remove(repoPath); + }) + .then(function() { + assert.equal(false, fse.existsSync(repoPath)); + }); + }); + + // THIS TEST MAKES IT FAIL + it.skip("make remove repo fail 02", function() { + this.timeout(30000); + + var repo = this.repository; + var submodulePath = "nodegittest"; + var submoduleUrl = "https://github.com/nodegit/test.git"; + + var submodule; + var submoduleRepo; + + return NodeGit.Submodule.addSetup(repo, submoduleUrl, submodulePath, 0) + .then(function(_submodule) { + submodule = _submodule; + + return submodule.init(0); + }) + .then(function() { + return submodule.open(); + }) + .then(function(_submoduleRepo) { + submoduleRepo = _submoduleRepo; + return submoduleRepo.fetch("origin", null, null); + }) + .then(function() { + return repo.refreshIndex(); + }) + .then(function(index) { + return fse.remove(repoPath); + }) + .then(function() { + assert.equal(false, fse.existsSync(repoPath)); + }); + }); + + // THIS TEST MAKES IT FAIL + it.only("make remove repo fail 03", function() { + this.timeout(30000); + + var repo = this.repository; + var submodulePath = "nodegittest"; + var submoduleUrl = "https://github.com/nodegit/test.git"; + + var submodule; + var submoduleRepo; + + return NodeGit.Submodule.addSetup(repo, submoduleUrl, submodulePath, 0) + .then(function(_submodule) { + submodule = _submodule; + + return submodule.init(0); + }) + .then(function() { + return submodule.open(); + }) + .then(function(_submoduleRepo) { + submoduleRepo = _submoduleRepo; + return submoduleRepo.fetch("origin", null, null); + }) + .then(function() { + return fse.remove(repoPath); + }) + .then(function() { + assert.equal(false, fse.existsSync(repoPath)); + }); + }); + it("can run sync callback without deadlocking", function() { var repo = this.workdirRepository; var submodules = [];