forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepo.js
More file actions
57 lines (51 loc) · 1.61 KB
/
repo.js
File metadata and controls
57 lines (51 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var git = require('../'),
rimraf = require('rimraf'),
fs = require( 'fs' );
/**
* Repo
* Ensure the repo method can handle opening repositories with async/sync
* signatures properly.
*/
exports.openInvalidRepo = function(test){
test.expect(1);
// Test invalid repository
git.Repo.open('repos/nonrepo', function(error, repository) {
test.ok(error instanceof Error);
test.done();
});
};
exports.openValidRepo = function(test){
test.expect(1);
// Test valid repository
git.Repo.open('repos/workdir/.git', function(error, repository) {
test.equals(null, error, 'Valid repository error code');
test.done();
});
};
/**
* Ensure repo doesn't attempt to open missing directories
*/
exports.nonexistentDirectory = function(test) {
test.expect(2);
git.Repo.open('/surely/this/directory/does/not/exist/on/this/machine', function(error, repository) {
test.notEqual(error, null, 'Attempting to open a nonexistent directory should error');
test.equals(repository, null, 'Non existent directory should result in null repository');
test.done();
});
};
/**
* Ensure the init method can create repositories at the destination path and
* can create either bare/non-bare.
*/
exports.init = function(test) {
test.expect(2);
// Create bare repo and test for creation
git.Repo.init('repos/newrepo', true, function(error, path, isBare) {
test.equals(null, error, 'Successfully created bare repository');
// Verify repo exists
git.Repo.open('repos/newrepo', function(error, path, repo) {
test.equals(null, error, 'Valid repository created');
test.done();
});
});
};