feat: 초기 프로젝트 설정 및 룰.md 파일 추가
This commit is contained in:
48
api.hyungi.net/node_modules/js-git/test/run.js
generated
vendored
Normal file
48
api.hyungi.net/node_modules/js-git/test/run.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
// Ultra simple test runner with TAP output.
|
||||
|
||||
var inspect = require('util').inspect;
|
||||
var defer = require('../lib/defer.js');
|
||||
var log = console.log;
|
||||
console.log = function () {
|
||||
var args = [].slice.call(arguments).map(function (arg) {
|
||||
return inspect(arg, {colors:true});
|
||||
});
|
||||
log(args.join(" ").split("\n").map(function (line) {
|
||||
return "# " + line;
|
||||
}).join("\n"));
|
||||
};
|
||||
|
||||
module.exports = function (tests) {
|
||||
var timeout;
|
||||
var test;
|
||||
var index = 0;
|
||||
log("1.." + (tests.length));
|
||||
next();
|
||||
function next(err) {
|
||||
if (timeout) clearTimeout(timeout);
|
||||
if (index) {
|
||||
if (err) {
|
||||
log(err.stack.split("\n").map(function (line) {
|
||||
return "# " + line;
|
||||
}).join("\n"));
|
||||
log("not ok " + index + " - " + test.name);
|
||||
}
|
||||
else {
|
||||
log("ok " + index + " - " + test.name);
|
||||
}
|
||||
}
|
||||
test = tests[index++];
|
||||
if (!test) return;
|
||||
timeout = setTimeout(onTimeout, 1000);
|
||||
try {
|
||||
if (test.length) test(next);
|
||||
else test();
|
||||
}
|
||||
catch (err) { return next(err); }
|
||||
if (!test.length) defer(next);
|
||||
}
|
||||
|
||||
function onTimeout() {
|
||||
next(new Error("Test timeout"));
|
||||
}
|
||||
};
|
||||
5
api.hyungi.net/node_modules/js-git/test/sample-pack.js
generated
vendored
Normal file
5
api.hyungi.net/node_modules/js-git/test/sample-pack.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
var bodec = require('bodec');
|
||||
|
||||
// This is a small sample packfile with couple offset deltas
|
||||
// pack-5851ce932ec42973b51d631afe25da247c3dc49a.pack
|
||||
module.exports = bodec.fromBase64('UEFDSwAAAAIAAAAQnQ54nJ3MWwoCMQxA0f+uIhtQ0nYeKYgobsENZNoEC/OQMTK6e2cN/l4411YRYCo5kseITVLpSmAfOVLSnFJB6kJqSukDuSevMhu0moed9CmrKjKFwpIxtT7TINh2vSqReHX8tseywr1OcOPXJuMIJ6vTJa/CVpe5fo55mc7gY2p86LFBOGCH6PY6VTP5x7prKfAVA54Xe+yLWTbQOor7AZUCSPmRDnicnctRCgIhEADQf08xFyjGUVeFiKIrdAEdZ0lYd8OM7fh1hn4fvNFFQEi8JCcuCoWSmakwY8xoHGMxkdgimZjVM3VZB8wUPMUJLWrRPml0IdspuJl1JHJBSijGRlLpPR5bh3ttcEuvXZYFTqO2C3dJo25r/Rx5a2fQJlpNHgnhgBOi+mmrY8g/V11LgVV2mOsi6guDiEL9mA94nJ3PTWrDMBBA4b1OMRdosDT6hRIKvkIuIMkjd6htGXVCkts3Z+j2wbd4MohA+5Cai874uiQXQmuIjagsAWMp3rWS0WCM6syDDgGbDCXEmhz5Zl00iayv2mpyHk2xVLVZlhJUvst3H3DjHeb8+6Btg0/h/asOysL94Oel9v0KGpPVxjtE+Jj8NKl33VmE/mPV3M8XrO8x4WOFkusPSIc+eOUjb9B4I/UHHmNMM5QOeJydy1sKwjAQRuH3rGI2oGQmlzYgIrgDcQNp8hcDTSsxostXt+B5/OD0BpAzMJmzJJs4J5Fh5OiCsB3nMFvoOAakkaHusWHtpJm1y9YYb4KXSawgR/GY9MQ+8OB/TZhVfPbb1uhaKp3j44VloUMv9ZQaYi/bWt77tNUjsQmWxTttaae91uqrtfSOf151wRorqN9Ac1mgPgYNRBeSDnicncvdCcIwEADg90xxCyiXn6YGRBRXcIG75IKBppX2xI6vM/j6waerCGAozFyCiA2Jx+QJh5Rd8l5cHUiSdcVTzeZFq8wKY5TkamYsIWO1Xkau8VRdHNhF5BLJsUWqht76XFZ4tA532j4yTXDW1q95FdK2zG0/5qVfwPoUrIshWThgRDQ/7U1V/rnmVgpsSxdQ2dV8AbwRRT6TC3icnczNCQIxEEDhe6qYBpT8JwuyCHvybgOTmOBAsoE4ouUrluD1wfd4lgLexpqjL9G5kG6YUtY56ohqccbVaEzQoaLXAp98HxOu1GHDx6u0Biemfs6zINPY6X3Mo6+gzGKV9jYEOEgvpfjWTszlHysuOzFhg+03ER9fQDcKqQl4nDM0MDAzMVFIL0pNLcnMS9crqShhEHwQ5TRdT6bE+tY/8blzjRyr9lYcMoSoy60kVmVeajlYifjVm28/SzW0d12ZKCB++trFC8ZKOxBKjMBqauylWlkm6kbyCrH0Gp01vHQ9NnMNAFftOrq1AXic80jNyclXCM8vyknhckxJUSjOz03lAgBQjAcOPXicS8zLL8lILVJIy8xJ5QIAI9cEvLEBeJyrTC1RSMzLL8lILVJIy8xJ5QIAOsAGLmWAPnicm8lYOqEUAAX6AhVkEHicKw2aEAQABEABqqoCeJwzNDAwMzFRyK1ML0pNLcnMS9crqShhEHwQ5TRdT6bE+tY/8blzjRyr9lYcAgAxUhBDqAJ4nDM0MDAzMVFIL0pNLcnMS9crqShhEHwQ5TRdT6bE+tY/8blzjRyr9lYcAgAPuQ9dqAJ4nDM0MDAzMVFIL0pNLcnMS9crqShhCK3dYPty+oksL6Y+ub1WMq+Voh9ZAAAZvA8xPHic80jNyclXCM8vyknhAgAcMgQnuZAj3ZpSLQckQi9VfpQYWt+hefM=');
|
||||
69
api.hyungi.net/node_modules/js-git/test/test-config-codec.js
generated
vendored
Normal file
69
api.hyungi.net/node_modules/js-git/test/test-config-codec.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
var run = require('./run.js');
|
||||
|
||||
// The thing we mean to test.
|
||||
var codec = require('../lib/config-codec.js');
|
||||
|
||||
var sample = '\
|
||||
[user]\n\
|
||||
\tname = Tim Caswell\n\
|
||||
\temail = tim@creationix.com\n\
|
||||
[core]\n\
|
||||
\teditor = vim\n\
|
||||
\twhitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol\n\
|
||||
[web]\n\
|
||||
\tbrowser = google-chrome\n\
|
||||
[color]\n\
|
||||
\tui = true\n\
|
||||
[color "branch"]\n\
|
||||
\tcurrent = yellow bold\n\
|
||||
\tlocal = green bold\n\
|
||||
\tremote = cyan bold\n\
|
||||
[color "diff"]\n\
|
||||
\tmeta = yellow bold\n\
|
||||
\tfrag = magenta bold\n\
|
||||
\told = red bold\n\
|
||||
\tnew = green bold\n\
|
||||
\twhitespace = red reverse\n\
|
||||
[github]\n\
|
||||
\tuser = creationix\n\
|
||||
\ttoken = token';
|
||||
|
||||
var config;
|
||||
|
||||
run([
|
||||
function testDecode() {
|
||||
config = codec.decode(sample);
|
||||
if (config.user.name !== "Tim Caswell") {
|
||||
throw new Error("Failed to parse user.name");
|
||||
}
|
||||
if (config.color.ui != "true") {
|
||||
throw new Error("Failed to parse color.ui");
|
||||
}
|
||||
if (config.color.diff.meta !== "yellow bold") {
|
||||
throw new Error("Failed to parse color.diff.meta");
|
||||
}
|
||||
},
|
||||
function testEncode() {
|
||||
var encoded = codec.encode(config);
|
||||
var config2 = codec.decode(encoded);
|
||||
if (JSON.stringify(config) !== JSON.stringify(config2)) {
|
||||
console.log(config);
|
||||
console.log(encoded);
|
||||
console.log(config2);
|
||||
throw new Error("Encode failed");
|
||||
}
|
||||
},
|
||||
function testEncode2() {
|
||||
var encoded = codec.encode({
|
||||
foo: {
|
||||
bar: {
|
||||
baz: true
|
||||
}
|
||||
}
|
||||
});
|
||||
if (encoded !== '[foo "bar"]\n\tbaz = true\n') {
|
||||
console.log(encoded);
|
||||
throw new Error("Invalid encoding of single deep config");
|
||||
}
|
||||
}
|
||||
]);
|
||||
57
api.hyungi.net/node_modules/js-git/test/test-mem-db.js
generated
vendored
Normal file
57
api.hyungi.net/node_modules/js-git/test/test-mem-db.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
var run = require('./run.js');
|
||||
var bodec = require('bodec');
|
||||
var sha1 = require('git-sha1');
|
||||
var codec = require('../lib/object-codec.js');
|
||||
|
||||
var repo = {};
|
||||
require('../mixins/mem-db.js')(repo);
|
||||
|
||||
var blob = bodec.fromUnicode("Hello World\n");
|
||||
var blobHash = "557db03de997c86a4a028e1ebd3a1ceb225be238";
|
||||
run([
|
||||
function testSaveAs(end) {
|
||||
repo.saveAs("blob", blob, function (err, hash) {
|
||||
if (err) return end(err);
|
||||
if (hash !== blobHash) {
|
||||
console.log([hash, blobHash]);
|
||||
return end(new Error("Hash mismatch"));
|
||||
}
|
||||
end();
|
||||
});
|
||||
},
|
||||
function testLoadRaw(end) {
|
||||
repo.loadRaw(blobHash, function (err, bin) {
|
||||
if (err) return end(err);
|
||||
var obj = codec.deframe(bin, true);
|
||||
if (obj.type !== "blob") return err(new Error("Wrong type"));
|
||||
if (bodec.toUnicode(obj.body) !== bodec.toUnicode(blob)) {
|
||||
return err(new Error("Wrong body"));
|
||||
}
|
||||
end();
|
||||
});
|
||||
},
|
||||
function testLoadAs(end) {
|
||||
repo.loadAs("blob", blobHash, function (err, body) {
|
||||
if (err) return end(err);
|
||||
if (bodec.toUnicode(body) !== bodec.toUnicode(blob)) {
|
||||
return err(new Error("Wrong body"));
|
||||
}
|
||||
end();
|
||||
});
|
||||
},
|
||||
function testSaveRaw(end) {
|
||||
var newBody = bodec.fromUnicode("A new body\n");
|
||||
var bin = codec.frame({type:"blob",body:newBody});
|
||||
var hash = sha1(bin);
|
||||
repo.saveRaw(hash, bin, function (err) {
|
||||
if (err) return end(err);
|
||||
repo.loadAs("blob", hash, function (err, body) {
|
||||
if (err) return end(err);
|
||||
if (bodec.toUnicode(body) !== bodec.toUnicode(newBody)) {
|
||||
return end(new Error("Body mismatch"));
|
||||
}
|
||||
end();
|
||||
});
|
||||
});
|
||||
}
|
||||
]);
|
||||
212
api.hyungi.net/node_modules/js-git/test/test-object-codec.js
generated
vendored
Normal file
212
api.hyungi.net/node_modules/js-git/test/test-object-codec.js
generated
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
var modes = require('../lib/modes.js');
|
||||
var bodec = require('bodec');
|
||||
var sha1 = require('git-sha1');
|
||||
var run = require('./run.js');
|
||||
|
||||
// The thing we mean to test.
|
||||
var codec = require('../lib/object-codec.js');
|
||||
|
||||
var blobHash, treeHash, commitHash, tagHash;
|
||||
var blob, tree, commit, tag;
|
||||
var blobBin, treeBin, commitBin, tagBin;
|
||||
|
||||
run([
|
||||
function testEncodeBlob() {
|
||||
blob = bodec.fromUnicode("Hello World\n");
|
||||
blobBin = codec.frame({type: "blob", body: blob});
|
||||
blobHash = sha1(blobBin);
|
||||
if (blobHash !== '557db03de997c86a4a028e1ebd3a1ceb225be238') {
|
||||
throw new Error("Invalid blob hash");
|
||||
}
|
||||
},
|
||||
function testEncodeBlobInvalidType() {
|
||||
try {
|
||||
codec.frame({type: "blob", body: "Not a binary value"});
|
||||
}
|
||||
catch (err) {
|
||||
return;
|
||||
}
|
||||
throw new Error("Expected an error when passin in a non-binary blob");
|
||||
},
|
||||
function testEncodeTree() {
|
||||
tree = {
|
||||
"greeting.txt": {
|
||||
mode: modes.file,
|
||||
hash: blobHash
|
||||
}
|
||||
};
|
||||
treeBin = codec.frame({type: "tree", body: tree});
|
||||
treeHash = sha1(treeBin);
|
||||
if (treeHash !== "648fc86e8557bdabbc2c828a19535f833727fa62") {
|
||||
throw new Error("Invalid tree hash");
|
||||
}
|
||||
},
|
||||
function testTreeSort() {
|
||||
var tree = {
|
||||
"README.md": {"mode":modes.blob,"hash":"42bd87a816800cb87646e95b71273983a71a26dc"},
|
||||
"a.js": {"mode":modes.blob,"hash":"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"},
|
||||
"a-js": {"mode":modes.blob,"hash":"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"},
|
||||
"b": {"mode":modes.blob,"hash":"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"},
|
||||
"b-js": {"mode":modes.blob,"hash":"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"},
|
||||
"c": {"mode":modes.blob,"hash":"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"},
|
||||
"c.js": {"mode":modes.blob,"hash":"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"},
|
||||
"a": {"mode":modes.tree,"hash":"496d6428b9cf92981dc9495211e6e1120fb6f2ba"},
|
||||
"b.js": {"mode":modes.tree,"hash":"496d6428b9cf92981dc9495211e6e1120fb6f2ba"},
|
||||
"c-js": {"mode":modes.tree,"hash":"496d6428b9cf92981dc9495211e6e1120fb6f2ba"},
|
||||
};
|
||||
var treeBin = codec.frame({type: "tree", body: tree});
|
||||
var treeHash = sha1(treeBin);
|
||||
if (treeHash !== "f78893bf52bc695f343372d4210c8c0803c7c4db") {
|
||||
throw new Error("Invalid tree hash");
|
||||
}
|
||||
},
|
||||
function testEncodeCommit() {
|
||||
var person = {
|
||||
name: "Tim Caswell",
|
||||
email: "tim@creationix.com",
|
||||
date: {
|
||||
seconds: 1391790884,
|
||||
offset: 7 * 60
|
||||
}
|
||||
};
|
||||
commit = {
|
||||
tree: treeHash,
|
||||
author: person,
|
||||
committer: person,
|
||||
message: "Test Commit\n",
|
||||
parents: []
|
||||
};
|
||||
commitBin = codec.frame({type: "commit", body: commit});
|
||||
commitHash = sha1(commitBin);
|
||||
if (commitHash !== "500c37fc17988b90c82d812a2d6fc25b15354bf2") {
|
||||
throw new Error("Invalid commit hash");
|
||||
}
|
||||
},
|
||||
function testEncodeTag() {
|
||||
tag = {
|
||||
object: commitHash,
|
||||
type: "commit",
|
||||
tag: "mytag",
|
||||
tagger: {
|
||||
name: "Tim Caswell",
|
||||
email: "tim@creationix.com",
|
||||
date: {
|
||||
seconds: 1391790910,
|
||||
offset: 7 * 60
|
||||
}
|
||||
},
|
||||
message: "Tag it!\n"
|
||||
};
|
||||
tagBin = codec.frame({type: "tag", body: tag});
|
||||
tagHash = sha1(tagBin);
|
||||
if (tagHash !== "49522787662a0183652dc9cafa5c008b5a0e0c2a") {
|
||||
throw new Error("Invalid tag hash");
|
||||
}
|
||||
},
|
||||
function testDecodeTag() {
|
||||
var obj = codec.deframe(tagBin, true);
|
||||
if (obj.type !== "tag") throw new Error("Invalid type");
|
||||
if (!(obj.body.object === tag.object && obj.body.message === tag.message)) {
|
||||
throw new Error("Problem decoding");
|
||||
}
|
||||
},
|
||||
function testDecodeCommit() {
|
||||
var obj = codec.deframe(commitBin, true);
|
||||
if (obj.type !== "commit") throw new Error("Invalid type");
|
||||
if (!(obj.body.tree === commit.tree &&
|
||||
obj.body.message === commit.message &&
|
||||
obj.body.author.date.seconds === commit.author.date.seconds)) {
|
||||
throw new Error("Problem decoding");
|
||||
}
|
||||
},
|
||||
function testDecodeTree() {
|
||||
var obj = codec.deframe(treeBin, true);
|
||||
if (obj.type !== "tree") throw new Error("Invalid type");
|
||||
if (obj.body["greeting.txt"].hash !== tree["greeting.txt"].hash) {
|
||||
throw new Error("Problem decoding");
|
||||
}
|
||||
},
|
||||
function testDecodeBlob() {
|
||||
var obj = codec.deframe(blobBin, true);
|
||||
if (obj.type !== "blob") throw new Error("Invalid type");
|
||||
if (bodec.toUnicode(obj.body) !== bodec.toUnicode(blob)) {
|
||||
throw new Error("Problem decoding");
|
||||
}
|
||||
},
|
||||
function testUnicodeFilePath() {
|
||||
var name = "æðelen";
|
||||
var tree = {};
|
||||
tree[name] = {
|
||||
mode: modes.file,
|
||||
hash: blobHash
|
||||
};
|
||||
var bin = codec.frame({type:"tree", body: tree});
|
||||
var obj = codec.deframe(bin, true);
|
||||
var newName = Object.keys(obj.body)[0];
|
||||
if (newName !== name) {
|
||||
console.log(newName + " != " + name);
|
||||
throw new Error("Problem storing and retrieving utf8 paths");
|
||||
}
|
||||
if (obj.body[name].hash !== tree[name].hash) {
|
||||
throw new Error("Problem decoding hash hex");
|
||||
}
|
||||
},
|
||||
function testUnicodeCommit() {
|
||||
var person = {
|
||||
name: "Laȝamon",
|
||||
email: "laȝamon@chronicles-of-england.org",
|
||||
date: {
|
||||
seconds: 1391790910,
|
||||
offset: 7 * 60
|
||||
}
|
||||
};
|
||||
var commit = {
|
||||
tree: treeHash,
|
||||
author: person,
|
||||
committer: person,
|
||||
message: "An preost wes on leoden, Laȝamon was ihoten\nHe wes Leovenaðes sone -- liðe him be Drihten\n",
|
||||
parents: []
|
||||
};
|
||||
var bin = codec.frame({type:"commit", body:commit});
|
||||
var obj = codec.deframe(bin, true);
|
||||
if (commit.author.name !== obj.body.author.name ||
|
||||
commit.author.email !== obj.body.author.email ||
|
||||
commit.message !== obj.body.message) {
|
||||
console.log([obj.body.author, obj.body.message]);
|
||||
throw new Error("Problem decoding utf8 parts in commit");
|
||||
}
|
||||
},
|
||||
function testUnicodeTag() {
|
||||
var tag = {
|
||||
object: commitHash,
|
||||
type: "commit",
|
||||
tag: "Laȝamon",
|
||||
tagger: {
|
||||
name: "Laȝamon",
|
||||
email: "laȝamon@chronicles-of-england.org",
|
||||
date: {
|
||||
seconds: 1391790910,
|
||||
offset: 7 * 60
|
||||
}
|
||||
},
|
||||
message: "He wonede at Ernleȝe at æðelen are chirechen,\nUppen Sevarne staþe, sel þar him þuhte,\nOnfest Radestone, þer he bock radde.\n"
|
||||
};
|
||||
var bin = codec.frame({type:"tag", body:tag});
|
||||
var obj = codec.deframe(bin, true);
|
||||
if (tag.tagger.name !== obj.body.tagger.name ||
|
||||
tag.tagger.email !== obj.body.tagger.email ||
|
||||
tag.message !== obj.body.message) {
|
||||
console.log([obj.body.tagger, obj.body.message]);
|
||||
throw new Error("Problem decoding utf8 parts in tag");
|
||||
}
|
||||
},
|
||||
function testBinaryBlob() {
|
||||
var blob = bodec.create(256);
|
||||
for (var i = 0; i < 256; i++) { blob[i] = i; }
|
||||
var bin = codec.frame({type:"blob",body:blob});
|
||||
var obj = codec.deframe(bin, true);
|
||||
if (bodec.toRaw(blob) !== bodec.toRaw(obj.body)) {
|
||||
throw new Error("Problem decoding binary blob");
|
||||
}
|
||||
}
|
||||
]);
|
||||
100
api.hyungi.net/node_modules/js-git/test/test-pack-codec.js
generated
vendored
Normal file
100
api.hyungi.net/node_modules/js-git/test/test-pack-codec.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
var bodec = require('bodec');
|
||||
var run = require('./run.js');
|
||||
var decoders = require('../lib/object-codec.js').decoders;
|
||||
var encoders = require('../lib/object-codec.js').encoders;
|
||||
|
||||
// The thing we mean to test.
|
||||
var codec = require('../lib/pack-codec.js');
|
||||
|
||||
var pack = require('./sample-pack.js');
|
||||
var items = [];
|
||||
var newPack;
|
||||
|
||||
function unpackStream(stream) {
|
||||
var meta, out = [], finished = false;
|
||||
var write = codec.decodePack(onItem);
|
||||
for (var i = 0, l = stream.length; i < l; i += 128) {
|
||||
var slice = bodec.slice(stream, i, i + 128);
|
||||
try {
|
||||
// console.log("SLICE", slice);
|
||||
write(slice);
|
||||
}
|
||||
catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
write();
|
||||
|
||||
function onItem(item) {
|
||||
// console.log("UNPACK", item);
|
||||
if (item === undefined) {
|
||||
finished = true;
|
||||
}
|
||||
else if (!meta) {
|
||||
meta = item;
|
||||
}
|
||||
else {
|
||||
out.push(item);
|
||||
}
|
||||
}
|
||||
if (!finished) throw new Error("unpack stream didn't finish");
|
||||
if (out.length !== meta.num) throw new Error("Item num mismatch");
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
run([
|
||||
function testDecodePack() {
|
||||
var counts = {};
|
||||
items = unpackStream(pack).map(function (item) {
|
||||
counts[item.type] = counts[item.type] || 0;
|
||||
counts[item.type]++;
|
||||
if (item.type === "tree" || item.type === "tag" || item.type === "commit") {
|
||||
item.body = decoders[item.type](item.body);
|
||||
}
|
||||
return item;
|
||||
});
|
||||
if (counts.commit !== 6) throw new Error("Wrong number of commits parsed");
|
||||
if (counts.tree !== 4) throw new Error("Wrong number of trees parsed");
|
||||
if (counts.blob !== 4) throw new Error("Wrong number of blobs parsed");
|
||||
if (counts['ofs-delta'] !== 2) throw new Error("Wrong number of offset deltas parsed");
|
||||
},
|
||||
function testEncodePack() {
|
||||
var done = false;
|
||||
var outs = [];
|
||||
|
||||
var write = codec.encodePack(function (item) {
|
||||
if (item === undefined) {
|
||||
done = true;
|
||||
return;
|
||||
}
|
||||
if (!bodec.isBinary(item)) throw new Error("encode output must be buffers");
|
||||
outs.push(item);
|
||||
});
|
||||
write({num:items.length});
|
||||
items.forEach(function (item) {
|
||||
if (!bodec.isBinary(item.body)) {
|
||||
item.body = encoders[item.type](item.body);
|
||||
}
|
||||
write(item);
|
||||
});
|
||||
write();
|
||||
|
||||
if (!done) throw new Error("Output stream never ended");
|
||||
|
||||
newPack = bodec.join(outs);
|
||||
},
|
||||
function verifyEncodePack() {
|
||||
try {
|
||||
unpackStream(newPack);
|
||||
if (bodec.toHex(pack) !== bodec.toHex(newPack)) {
|
||||
throw new Error("Final pack doesn't match original.");
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.log(bodec.toHex(pack));
|
||||
console.log(bodec.toHex(newPack));
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
]);
|
||||
55
api.hyungi.net/node_modules/js-git/test/test-pack-ops.js
generated
vendored
Normal file
55
api.hyungi.net/node_modules/js-git/test/test-pack-ops.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
var run = require('./run.js');
|
||||
|
||||
var repo = {};
|
||||
require('../mixins/mem-db.js')(repo);
|
||||
|
||||
var pack = require('./sample-pack.js');
|
||||
var hashes;
|
||||
|
||||
run([
|
||||
function setup() {
|
||||
require('../mixins/pack-ops.js')(repo);
|
||||
},
|
||||
function testUnpack(end) {
|
||||
repo.unpack(singleStream(pack), {
|
||||
onProgress: onProgress
|
||||
}, function (err, result) {
|
||||
if (err) return end(err);
|
||||
hashes = result;
|
||||
if (hashes.length !== 16) {
|
||||
return end(new Error("Wrong number of objects unpacked"));
|
||||
}
|
||||
end();
|
||||
});
|
||||
function onProgress(progress) {
|
||||
// console.log(progress);
|
||||
}
|
||||
},
|
||||
function testPack(end) {
|
||||
var stream;
|
||||
var parts = [];
|
||||
repo.pack(hashes, {}, function (err, result) {
|
||||
if (err) return end(err);
|
||||
stream = result;
|
||||
stream.take(onRead);
|
||||
});
|
||||
function onRead(err, chunk) {
|
||||
if (err) return end(err);
|
||||
// console.log(chunk);
|
||||
if (chunk) {
|
||||
parts.push(chunk);
|
||||
return stream.take(onRead);
|
||||
}
|
||||
end();
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
function singleStream(item) {
|
||||
var done = false;
|
||||
return { take: function (callback) {
|
||||
if (done) return callback();
|
||||
done = true;
|
||||
callback(null, item);
|
||||
}};
|
||||
}
|
||||
44
api.hyungi.net/node_modules/js-git/test/test-zlib.js
generated
vendored
Normal file
44
api.hyungi.net/node_modules/js-git/test/test-zlib.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
var run = require('./run.js');
|
||||
var bodec = require('bodec');
|
||||
|
||||
// The thing we mean to test.
|
||||
var inflate = require('../lib/inflate.js');
|
||||
var deflate = require('../lib/deflate.js');
|
||||
var inflateStream = require('../lib/inflate-stream.js');
|
||||
|
||||
var bin = bodec.create(1024);
|
||||
for (var i = 0; i < 1024; i++) {
|
||||
bin[i] = i >> 2 | i % 4 & 0x7f;
|
||||
}
|
||||
|
||||
run([
|
||||
function testRoundTrip() {
|
||||
var deflated = deflate(bin);
|
||||
if (!bodec.isBinary(deflated)) {
|
||||
throw new Error("deflate output should be native binary");
|
||||
}
|
||||
var inflated = inflate(deflated);
|
||||
if (!bodec.isBinary(inflated)) {
|
||||
throw new Error("inflate output should be native binary");
|
||||
}
|
||||
if (bodec.toRaw(bin) !== bodec.toRaw(inflated)) {
|
||||
console.log([bin, inflated]);
|
||||
throw new Error("Problem with roundtrip");
|
||||
}
|
||||
},
|
||||
function testStream() {
|
||||
var done = false;
|
||||
var chunks = [];
|
||||
var deflated = deflate(bin);
|
||||
var inf = inflateStream();
|
||||
|
||||
for (var i = 0, l = deflated.length; i < l; ++i) {
|
||||
inf.write(deflated[i]);
|
||||
}
|
||||
var inflated = inf.flush();
|
||||
if (bodec.toRaw(bin) !== bodec.toRaw(inflated)) {
|
||||
console.log([bin.length, inflated.length]);
|
||||
throw new Error("Problem with roundtrip");
|
||||
}
|
||||
}
|
||||
]);
|
||||
Reference in New Issue
Block a user