mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-22 16:01:16 +01:00
Add more tests
This commit is contained in:
parent
30f1052f90
commit
5fc0f8b59a
@ -94,13 +94,6 @@ function store_cape(uuid, profile, details, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_from_array(arr, item) {
|
|
||||||
var i;
|
|
||||||
while((i = arr.indexOf(item)) !== -1) {
|
|
||||||
arr.splice(i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// downloads the images for +uuid+ while checking the cache
|
// downloads the images for +uuid+ while checking the cache
|
||||||
// status based on +details+. +whichhash+ specifies which
|
// status based on +details+. +whichhash+ specifies which
|
||||||
// image is more important, and should be called back on
|
// image is more important, and should be called back on
|
||||||
|
|||||||
@ -99,8 +99,10 @@ exp.open_skin = function(uuid, skinpath, callback) {
|
|||||||
fs.readFile(skinpath, function(err, buf) {
|
fs.readFile(skinpath, function(err, buf) {
|
||||||
if (err) {
|
if (err) {
|
||||||
logging.error(uuid + " error while opening skin file: " + err);
|
logging.error(uuid + " error while opening skin file: " + err);
|
||||||
|
callback(err, null)
|
||||||
|
} else {
|
||||||
|
callback(null, buf);
|
||||||
}
|
}
|
||||||
callback(err, buf);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
40
test/test.js
40
test/test.js
@ -165,6 +165,12 @@ describe("Crafatar", function() {
|
|||||||
});
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
it("should not find the file", function(done) {
|
||||||
|
skins.open_skin("TestUUID", 'non/existant/path', function(err, img) {
|
||||||
|
assert.notStrictEqual(err, null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// we have to make sure that we test both a 32x64 and 64x64 skin
|
// we have to make sure that we test both a 32x64 and 64x64 skin
|
||||||
@ -190,6 +196,39 @@ describe("Crafatar", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it("should already exist", function(done) {
|
||||||
|
before(function() {
|
||||||
|
cache.get_redis().flushall();
|
||||||
|
});
|
||||||
|
helpers.get_cape("Dinnerbone", function(err, hash, img) {
|
||||||
|
assert.strictEqual(err, null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("should not be found", function(done) {
|
||||||
|
helpers.get_cape("Jake0oo0", function(err, hash, img) {
|
||||||
|
assert.strictEqual(img, null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Networking: Skin", function() {
|
||||||
|
it("should not fail", function(done) {
|
||||||
|
helpers.get_cape("Jake0oo0", function(err, hash, img) {
|
||||||
|
assert.strictEqual(err, null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("should already exist", function(done) {
|
||||||
|
before(function() {
|
||||||
|
cache.get_redis().flushall();
|
||||||
|
});
|
||||||
|
helpers.get_cape("Jake0oo0", function(err, hash, img) {
|
||||||
|
assert.strictEqual(err, null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -213,7 +252,6 @@ describe("Crafatar", function() {
|
|||||||
});
|
});
|
||||||
it("should be cached", function(done) {
|
it("should be cached", function(done) {
|
||||||
helpers.get_avatar(id, false, 160, function(err, status, image) {
|
helpers.get_avatar(id, false, 160, function(err, status, image) {
|
||||||
console.log("STATUS: " + status)
|
|
||||||
assert.strictEqual(status === 0 || status === 1, true);
|
assert.strictEqual(status === 0 || status === 1, true);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user