mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
more tests w/ timeouts
This commit is contained in:
parent
42dae4582b
commit
3830b3ccf4
@ -45,7 +45,7 @@ exp.get_profile = function(uuid, callback) {
|
|||||||
// downloads skin file from +url+
|
// downloads skin file from +url+
|
||||||
// stores face image as +facename+
|
// stores face image as +facename+
|
||||||
// stores helm image as +helmname+
|
// stores helm image as +helmname+
|
||||||
// callback is forwarded from skins/extract_face or skins/extract_helm
|
// callback contains error
|
||||||
exp.skin_file = function(url, facename, helmname, callback) {
|
exp.skin_file = function(url, facename, helmname, callback) {
|
||||||
if (fs.existsSync(facename) && fs.existsSync(facename)) {
|
if (fs.existsSync(facename) && fs.existsSync(facename)) {
|
||||||
console.log("Images already exist, not downloading.");
|
console.log("Images already exist, not downloading.");
|
||||||
|
|||||||
35
test/test.js
35
test/test.js
@ -16,10 +16,11 @@ var usernames = fs.readFileSync('test/usernames.txt').toString().split("\n");
|
|||||||
var uuid = uuids[Math.round(Math.random() * (uuids.length - 1))];
|
var uuid = uuids[Math.round(Math.random() * (uuids.length - 1))];
|
||||||
var username = usernames[Math.round(Math.random() * (usernames.length - 1))];
|
var username = usernames[Math.round(Math.random() * (usernames.length - 1))];
|
||||||
|
|
||||||
describe('Avatar Serving', function(){
|
describe('UUID/username', function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
cache.get_redis().flushall();
|
cache.get_redis().flushall();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('UUID', function() {
|
describe('UUID', function() {
|
||||||
it("should be an invalid uuid", function(done) {
|
it("should be an invalid uuid", function(done) {
|
||||||
assert.strictEqual(helpers.uuid_valid("g098cb60fa8e427cb299793cbd302c9a"), false);
|
assert.strictEqual(helpers.uuid_valid("g098cb60fa8e427cb299793cbd302c9a"), false);
|
||||||
@ -59,14 +60,8 @@ describe('Avatar Serving', function(){
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should exist without skin", function(done) {
|
|
||||||
// profile 'Alex'
|
|
||||||
helpers.get_avatar("ec561538f3fd461daff5086b22154bce", false, 160, function(err, status, image) {
|
|
||||||
assert.strictEqual(status, 3);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Avatar', function() {
|
describe('Avatar', function() {
|
||||||
it("should be downloaded (uuid)", function(done) {
|
it("should be downloaded (uuid)", function(done) {
|
||||||
helpers.get_avatar(uuid, false, 160, function(err, status, image) {
|
helpers.get_avatar(uuid, false, 160, function(err, status, image) {
|
||||||
@ -92,7 +87,15 @@ describe('Avatar Serving', function(){
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it("should not exist (but account does)", function(done) {
|
||||||
|
// profile 'Alex'
|
||||||
|
helpers.get_avatar("ec561538f3fd461daff5086b22154bce", false, 160, function(err, status, image) {
|
||||||
|
assert.strictEqual(status, 3);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Mojang Errors', function() {
|
describe('Mojang Errors', function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
cache.get_redis().flushall();
|
cache.get_redis().flushall();
|
||||||
@ -103,5 +106,21 @@ describe('Avatar Serving', function(){
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it("should time out on profile download", function(done) {
|
||||||
|
config.http_timeout = 1;
|
||||||
|
networking.get_profile("069a79f444e94726a5befca90e38aaf5", function(err, profile) {
|
||||||
|
assert.strictEqual(err.code, "ETIMEDOUT");
|
||||||
|
config.http_timeout = 3000;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("should time out on skin download", function(done) {
|
||||||
|
config.http_timeout = 1;
|
||||||
|
networking.skin_file("http://textures.minecraft.net/texture/477be35554684c28bdeee4cf11c591d3c88afb77e0b98da893fd7bc318c65184", "face.png", "helm.png", function(err) {
|
||||||
|
assert.strictEqual(err.code, "ETIMEDOUT");
|
||||||
|
config.http_timeout = 3000;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user