forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathodb.js
More file actions
56 lines (44 loc) · 1.48 KB
/
Copy pathodb.js
File metadata and controls
56 lines (44 loc) · 1.48 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
var assert = require("assert");
var path = require("path");
describe("Odb", function() {
var reposPath = path.resolve("test/repos/workdir/.git");
var Repository = require("../../lib/repository");
var Oid = require("../../lib/oid");
var Obj = require("../../lib/object");
before(function() {
var test = this;
return Repository.open(reposPath).then(function(repo) {
test.repo = repo;
return repo;
}).then(function(repo) {
return repo.odb();
}).then(function(odb) {
test.odb = odb;
return odb;
});
});
it("can read raw objects directly from the odb using an OID", function() {
var oid = Oid.fromString("32789a79e71fbc9e04d3eff7425e1771eb595150");
return this.odb.read(oid).then(function (object) {
assert.equal(object.type(), Obj.TYPE.COMMIT);
});
});
it("can read objects directly from the odb using a string", function() {
return this.odb.read("32789a79e71fbc9e04d3eff7425e1771eb595150")
.then(function (object) {
assert.equal(object.type(), Obj.TYPE.COMMIT);
});
});
it("can write raw objects to git", function() {
var obj = "test data";
var odb = this.odb;
return odb.write(obj, obj.length, Obj.TYPE.BLOB).then(function(oid) {
assert.ok(oid instanceof Oid);
return odb.read(oid);
}).then(function(object) {
assert.equal(object.type(), Obj.TYPE.BLOB);
assert.equal(object.toString(), obj);
assert.equal(object.size(), obj.length);
});
});
});