mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-22 07:51:17 +01:00
no need to delete files, just flush redis :]
This commit is contained in:
parent
bdcd3e95c7
commit
be42030a0a
19
test/test.js
19
test/test.js
@ -5,28 +5,15 @@ var networking = require('../modules/networking');
|
|||||||
var helpers = require('../modules/helpers');
|
var helpers = require('../modules/helpers');
|
||||||
var config = require('../modules/config');
|
var config = require('../modules/config');
|
||||||
var skins = require('../modules/skins');
|
var skins = require('../modules/skins');
|
||||||
|
var redis = require('redis').createClient();
|
||||||
|
|
||||||
var uuids = fs.readFileSync('test/uuids.txt').toString().split("\r\n");
|
var uuids = fs.readFileSync('test/uuids.txt').toString().split("\r\n");
|
||||||
// Get a random UUID in order to prevent rate limiting
|
// Get a random UUID in order to prevent rate limiting
|
||||||
var uuid = uuids[Math.floor(Math.random() * uuids.length)];
|
var uuid = uuids[Math.floor(Math.random() * uuids.length)];
|
||||||
|
|
||||||
// Only deletes files, doesn't delete directory.
|
|
||||||
var deleteFolderRecursive = function(path) {
|
|
||||||
if( fs.existsSync(path) ) {
|
|
||||||
fs.readdirSync(path).forEach(function(file,index){
|
|
||||||
var curPath = path + "/" + file;
|
|
||||||
if(fs.lstatSync(curPath).isDirectory()) {
|
|
||||||
deleteFolderRecursive(curPath);
|
|
||||||
} else {
|
|
||||||
fs.unlinkSync(curPath);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('Avatar Serving', function(){
|
describe('Avatar Serving', function(){
|
||||||
before(function() {
|
before(function() {
|
||||||
deleteFolderRecursive('skins/');
|
redis.flushall();
|
||||||
});
|
});
|
||||||
describe('UUID', function(){
|
describe('UUID', function(){
|
||||||
it("should be an invalid uuid", function(done){
|
it("should be an invalid uuid", function(done){
|
||||||
@ -54,7 +41,7 @@ describe('Avatar Serving', function(){
|
|||||||
});
|
});
|
||||||
describe('Mojang Errors', function(){
|
describe('Mojang Errors', function(){
|
||||||
before(function() {
|
before(function() {
|
||||||
deleteFolderRecursive('skins/');
|
redis.flushall();
|
||||||
});
|
});
|
||||||
it("should be rate limited", function(done) {
|
it("should be rate limited", function(done) {
|
||||||
helpers.get_avatar(uuid, false, 180, function(err, status, image) {
|
helpers.get_avatar(uuid, false, 180, function(err, status, image) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user