forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblob.js
More file actions
53 lines (41 loc) · 1.34 KB
/
blob.js
File metadata and controls
53 lines (41 loc) · 1.34 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
var assert = require("assert");
var path = require("path");
var local = path.join.bind(path, __dirname);
describe("Blob", function() {
var NodeGit = require("../../");
var Oid = NodeGit.Oid;
var Repository = NodeGit.Repository;
var FileMode = NodeGit.TreeEntry.FILEMODE;
var reposPath = local("../repos/workdir");
var oid = "111dd657329797f6165f52f5085f61ac976dcf04";
beforeEach(function() {
var test = this;
return Repository.open(reposPath)
.then(function(repository) {
test.repository = repository;
return repository.getBlob(oid);
})
.then(function(blob) {
test.blob = blob;
});
});
it("can provide content as a buffer", function() {
var contents = this.blob.content();
assert.ok(Buffer.isBuffer(contents));
});
it("can provide content as a string", function() {
var contents = this.blob.toString();
assert.equal(typeof contents, "string");
assert.equal(contents.slice(0, 7), "@import");
});
it("can determine if a blob is not a binary", function() {
assert.equal(this.blob.filemode(), FileMode.BLOB);
});
it("can get a blob with an Oid object", function() {
var oidObject = Oid.fromString(oid);
return this.repository.getBlob(oidObject)
.then(function(blob) {
assert.equal(blob.id().toString(), oid);
});
});
});