/
repository.js
48 lines (38 loc) · 1.33 KB
/
repository.js
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
var assert = require("assert");
var path = require("path");
describe("Repository", function() {
var reposPath = path.resolve("test/repos/workdir/.git");
var newRepo = path.resolve("test/repos/newrepo");
var Repository = require("../../lib/repository");
var Index = require("../../lib/index");
before(function() {
var test = this;
return Repository.open(reposPath).then(function(repository) {
test.repository = repository;
});
});
it("can open a valid repository", function() {
assert.ok(this.repository instanceof Repository);
});
it("cannot open an invalid repository", function() {
return Repository.open("repos/nonrepo").then(null, function(err) {
assert.ok(err instanceof Error);
});
});
it("does not try to open paths that don't exist", function() {
var missingPath = "/surely/this/directory/does/not/exist/on/this/machine";
return Repository.open(missingPath).then(null, function(err) {
assert.ok(err instanceof Error);
});
});
it("can initialize a repository into a folder", function() {
return Repository.init(newRepo, 1).then(function(path, isBare) {
return Repository.open(newRepo);
});
});
it("can read the index", function() {
return this.repository.index().then(function(index) {
assert.ok(index instanceof Index);
});
});
});