Commit 67fc71da authored by Kurt Berglund's avatar Kurt Berglund

Test for treebuilder insert memory management

parent f1408478
......@@ -2,6 +2,8 @@ var assert = require("assert");
var path = require("path");
var local = path.join.bind(path, __dirname);
var leakTest = require("../utils/leak_test");
describe("TreeEntry", function() {
var NodeGit = require("../../");
var Repository = NodeGit.Repository;
......@@ -175,4 +177,15 @@ describe("TreeEntry", function() {
assert.equal(object.isTree(), true);
});
});
it("does not leak", function() {
var test = this;
return leakTest(NodeGit.TreeEntry, function() {
return test.commit.getTree()
.then(function(tree) {
return tree.entryByPath("example");
});
});
});
});
......@@ -5,10 +5,14 @@ var promisify = require("promisify-node");
var readDir = promisify(fs.readdir);
var local = path.join.bind(path, __dirname);
var leakTest = require("../utils/leak_test");
describe("TreeBuilder", function(){
var Git = require("../../");
var reposPath = local("../repos/workdir");
var oid = "111dd657329797f6165f52f5085f61ac976dcf04";
//setup test repo each test
beforeEach(function() {
var test = this;
......@@ -76,4 +80,19 @@ describe("TreeBuilder", function(){
return Git.Tree.lookup(test.repo, newTreeEntry.oid());
});
});
it("does not leak inserts", function() {
var test = this;
// The underlying C++ git_tree_entry is owned by the treebuilder that
// creates it. But since git_tree_entry is duplicable the generator will
// duplicate it and mark it as self freeing.
// Validate this with the leakTest.
return leakTest(Git.TreeEntry, function() {
return Git.Treebuilder.create(test.repo, null)
.then(function(builder) {
return builder.insert("test", oid, Git.TreeEntry.FILEMODE.BLOB);
});
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment