Skip to content

Commit 342b6e6

Browse files
committed
Converted to beforeEach for all tests
Added a new `beforeEach` to ensure repositories are cleaned in clone, not sure why this is required.
1 parent e19e8ea commit 342b6e6

File tree

14 files changed

+38
-29
lines changed

14 files changed

+38
-29
lines changed

test/tests/attr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("Attr", function() {
99

1010
var reposPath = local("../repos/workdir/.git");
1111

12-
before(function() {
12+
beforeEach(function() {
1313
var test = this;
1414

1515
return Repository.open(reposPath)

test/tests/blob.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe("Blob", function() {
1010
var reposPath = local("../repos/workdir/.git");
1111
var oid = "111dd657329797f6165f52f5085f61ac976dcf04";
1212

13-
before(function() {
13+
beforeEach(function() {
1414
var test = this;
1515

1616
return Repository.open(reposPath)

test/tests/branch.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,18 @@ describe("Branch", function() {
1111

1212
var reposPath = local("../repos/workdir/.git");
1313

14-
before(function() {
14+
beforeEach(function() {
1515
var test = this;
1616

1717
return Repository.open(reposPath)
1818
.then(function(repository) {
1919
test.repository = repository;
20-
});
21-
});
22-
23-
beforeEach(function() {
24-
var test = this;
25-
var repo = test.repository;
26-
27-
return repo.getMasterCommit()
20+
return repository.getMasterCommit();
21+
})
2822
.then(function(masterCommit) {
2923
test.masterCommit = masterCommit;
3024

31-
return repo.createBranch(branchName, masterCommit, true);
25+
return test.repository.createBranch(branchName, masterCommit, true);
3226
})
3327
.then(function(branch) {
3428
test.branch = branch;

test/tests/checkout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("Checkout", function() {
99
var packageJsonOid = "0fa56e90e096a4c24c785206b826ab914ea3de1e";
1010
var reposPath = local("../repos/workdir/.git");
1111

12-
before(function() {
12+
beforeEach(function() {
1313
var test = this;
1414

1515
return Repository.open(reposPath)

test/tests/clone.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ describe("Clone", function() {
1717
// Set a reasonable timeout here now that our repository has grown.
1818
this.timeout(30000);
1919

20+
beforeEach(function(done) {
21+
// In Windows if you do not clean up the repository, there may become a
22+
// conflict with file locking.
23+
if (this.repository && process.platform === "win32") {
24+
this.repository.stateCleanup();
25+
this.repository.free();
26+
delete this.repository;
27+
}
28+
29+
process.nextTick(function() {
30+
global.gc();
31+
done();
32+
});
33+
});
34+
2035
beforeEach(function() {
2136
return fse.remove(clonePath).catch(function(err) {
2237
console.log(err);

test/tests/commit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("Commit", function() {
2424
});
2525
}
2626

27-
before(function() {
27+
beforeEach(function() {
2828
return reinitialize(this);
2929
});
3030

test/tests/diff.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe("Diff", function() {
1414
var diffFilename = "wddiff.txt";
1515
var diffFilepath = local("../repos/workdir", diffFilename);
1616

17-
before(function() {
17+
beforeEach(function() {
1818
var test = this;
1919

2020
return Repository.open(reposPath).then(function(repository) {

test/tests/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe("Index", function() {
1414

1515
var reposPath = local("../repos/workdir/.git");
1616

17-
before(function() {
17+
beforeEach(function() {
1818
var test = this;
1919

2020
return Repository.open(reposPath)

test/tests/odb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("Odb", function() {
99

1010
var reposPath = local("../repos/workdir/.git");
1111

12-
before(function() {
12+
beforeEach(function() {
1313
var test = this;
1414

1515
return Repository.open(reposPath).then(function(repo) {

test/tests/remote.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe("Remote", function() {
1919
Remote.delete(repository, "test2");
2020
}
2121

22-
before(function() {
22+
beforeEach(function() {
2323
var test = this;
2424

2525
return Repository.open(reposPath)

0 commit comments

Comments
 (0)