Exemplo n.º 1
0
        function (error, response, data) {

            if (response.statusCode !== 200) {
                let apierror = new Error(`${response.req.path} returned the status code: ${response.statusCode}`);
                return opts.error(apierror, response);
            }

            if (!isJson(response)) {
                let apierror = new Error('url: ' + response.req.path + ' did not return JSON - please check your configuration');
                return opts.error(apierror, response);
            }

            if (!error) {
                data = JSON.parse(data);
                if (process.env.BSRECORD) {
                    let fs = require('fs-extra');
                    let filepath = require('url').parse(response.req.path).pathname.slice(1);
                    fs.ensureDir(path.dirname(path.join(__dirname, '../test/fixtures', filepath)));
                    fs.writeJSONFileSync(path.join(__dirname, '../test/fixtures', filepath), data);
                }
                return opts.cb(data, response);
            }

            return opts.error(error);
        }
Exemplo n.º 2
0
	it("should be able to fail on bad server", function(callback){
		var fn = path.join(tmpdir, 'fail.log');
		fs.writeJSONFileSync(fn,{});
		var cmd = bin + '  --server http://0.0.0.0:1 --file "'+fn+'"';
		createServerTest(cmd, function(err,stdout,stderr){
			fs.unlinkSync(fn);
			should(err).be.ok;
			should(err.code).equal(1);
			should(stdout).be.ok;
			should(stderr).be.not.ok;
			stdout.should.match(/Error connecting to http:\/\/0\.0\.0\.0\:1/);
			callback();
		});
	});
Exemplo n.º 3
0
	it("should be able to send log", function(callback){
		var fn = path.join(tmpdir, 'fail.log');
		fs.writeJSONFileSync(fn,{});
		var cmd = bin + '  --server http://0.0.0.0:{port}/logs --file "'+fn+'"';
		createServerTest(cmd, function(err,stdout,stderr,body,files){
			should(fs.existsSync(fn)).be.false;
			should(err).be.not.ok;
			should(stdout).be.ok;
			should(stderr).be.not.ok;
			stdout.should.match(/Done!/);
			should(body).be.ok;
			should(files).be.ok;
			should(body).have.property('count',1);
			should(body).have.property('platform',process.platform);
			should(body).have.property('ipaddress');
			should(body).have.property('user');
			should(files.file).be.an.object;
			should(files.file).have.property('name');
			should(files.file).have.property('type','application/octet-stream');
			callback();
		});
	});
Exemplo n.º 4
0
 }, function(err, data){
     newData = wow.processRaidData(data.progression.raids);
     console.log(util.inspect(newData, { hidden: true, colors: true }));
     fs.writeJSONFileSync(file, _.merge(apiData, newData));
     cb();
 })
Exemplo n.º 5
0
crimson.setConfig = function($val){
    fs.writeJSONFileSync(path.join(__dirname, '../config.json'), $val);
};