Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests ci #776

Merged
merged 2 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/agent/actions/fullwipe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exports.start = function(id, opts, cb) {

var opts = opts || {};
if (!opts || id == undefined || opts.token == undefined || opts.target == undefined){
let error = new Error('The factory reset data is not valid');
let error = new Error('The fullwipe data is not valid');
error.code = 2;
error.name = errors.find( x => x.status_code == error.code).message;
return cb(error);
Expand Down Expand Up @@ -96,4 +96,4 @@ exports.start = function(id, opts, cb) {

exports.stop = function(){
emitter = null;
}
}
7 changes: 5 additions & 2 deletions lib/agent/actions/geofencing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ exports.get_geofences = function (cb) {
exports.sync = function(id, geofences, cb) {
exports.watching = [];

if(!geofences || geofences.length == 0)
done(id, cb);

let fences = geofences;

// Se obtienen las zonas locales almacenadas
Expand Down Expand Up @@ -85,7 +88,7 @@ exports.sync = function(id, geofences, cb) {
target: 'geofencing',
reason: JSON.stringify(exports.watching)
}
api.push.methods['response'](data);
api.push.response(data);
cb();
}
}
Expand Down Expand Up @@ -123,4 +126,4 @@ function refresh_geofences(id, opts, cb) {

}

exports.start = exports.stop = refresh_geofences;
exports.start = exports.stop = refresh_geofences;
7 changes: 6 additions & 1 deletion lib/agent/plugins/control-panel/api/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ function format_url(endpoint) {
return '/devices/' + keys.get().device + '/' + endpoint + format;
}

exports.methods = {report, data, event, response};
exports.methods = {report, data, event, response};

exports.report = report;
exports.data = data;
exports.event = event;
exports.response = response;
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ var assert = require('assert'),
long_polling = require('..'),
hooks = require('../../../../hooks'),
common = require('../../../../../common'),
status = require('./../../../../triggers/status'),
status = require('../../../../triggers/status'),
EventEmitter = require('events').EventEmitter,
storage = require('./../../../../utils/storage'),
status_trigger = require('./../../../../triggers/status'),
server = require('./../server'),
storage = require('../../../../utils/storage'),
status_trigger = require('../../../../triggers/status'),
server = require('../server'),
test_server = require('./test_server');


Expand Down Expand Up @@ -288,4 +288,4 @@ describe('long-polling', function() {
});
});

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var fs = require('fs'),

var common = require('../../../common'),
hooks = require('../../../hooks'),
main = require('../'),
main = require('..'),
setup = require('../setup'),
api = require('../api'),
request = require('../api/request'),
Expand All @@ -18,21 +18,22 @@ var default_host = 'somewhere.com',

describe('main.load', function() {

// we roll our own fake config so we can control all its values
//we roll our own fake config so we can control all its values
var config = getset.load('/tmp/foo');

// insert default values to config
//insert default values to config
config.set('host', 'destination.com');
config.set('protocol', 'https');
config.global = { get: function() {} }

var background = false;

// object that is passed to plugin
//object that is passed to plugin
var common_obj = {
hooks : hooks,
logger : common.logger,
config : config,
system : common.system,
commands : {
perform: function(cmd) { /* noop */ },
},
Expand All @@ -43,13 +44,13 @@ describe('main.load', function() {
main.load.call(common_obj, cb)
}

// ok, since we're not testing the setup() function here, we'll stub
// it for all tests to prevent the execution to go any further.
// the tests at the bottom (that do check the setup()'s function result)
// will need to reset these stubs before they start.
//ok, since we're not testing the setup() function here, we'll stub
//it for all tests to prevent the execution to go any further.
//the tests at the bottom (that do check the setup()'s function result)
//will need to reset these stubs before they start.

// we also stub the long_polling.load, push.load and api.devices.get.status
// calls that are made on successful setup().
//we also stub the long_polling.load, push.load and api.devices.get.status
//calls that are made on successful setup().

var setup_stub;

Expand All @@ -74,7 +75,7 @@ describe('main.load', function() {
})

after(function() {
// reset the config obj
//reset the config obj
common_obj.config = config;
})

Expand Down Expand Up @@ -116,7 +117,7 @@ describe('main.load', function() {
describe('with invalid protocol', function() {

before(function() {
// Make sure we're using https protocol when running the whole test suite
//Make sure we're using https protocol when running the whole test suite
request.use({protocol: 'https'});
config.set('protocol', 'foo');
})
Expand All @@ -130,9 +131,9 @@ describe('main.load', function() {
it('does not trigger an error (regarding the protocol)', function(done) {
call(function(err) {

// here this error is from the semaphore we put on the setup.start() stub.
// so it's ok that we got it. we just want to check whether the invalid
// protocol, which should have been checked before, was the cause of the error, or not.
//here this error is from the semaphore we put on the setup.start() stub.
//so it's ok that we got it. we just want to check whether the invalid
//protocol, which should have been checked before, was the cause of the error, or not.
err.should.be.a.Error;
err.message.should.eql('Setup worked, but were stopping here.');
done();
Expand Down Expand Up @@ -212,7 +213,7 @@ describe('main.load', function() {
call(function() {

api.devices.get.status(function(err, url) {
url.should.not.containEql('///'); // if the host was empty, we'd get a URL containing three slashes
url.should.not.containEql('///'); //if the host was empty, we'd get a URL containing three slashes
needle_stub.restore();
keys_stub.restore();
done();
Expand Down Expand Up @@ -253,7 +254,7 @@ describe('main.load', function() {
config.set('host', default_host);
config.set('protocol', default_protocol);

background = false; // so we get a callback
background = false; //so we get a callback
});

it('calls setup()', function(done) {
Expand All @@ -266,7 +267,7 @@ describe('main.load', function() {

describe('if setup() failed', function() {

// the default setup_stub behaviour is good for this test.
//the default setup_stub behaviour is good for this test.

describe('and running on background', function() {

Expand All @@ -277,7 +278,7 @@ describe('main.load', function() {
background = true;
common.logger.pause();

// playing with fire here!
//playing with fire here!
setinterval_stub = sinon.stub(global, 'setInterval').callsFake((fn, delay) => {
if (delay === 10000)
setinterval_called = true;
Expand All @@ -286,7 +287,7 @@ describe('main.load', function() {
});

after(function() {
setinterval_stub.restore(); // or heaven will fall apart
setinterval_stub.restore(); //or heaven will fall apart
common.logger.resume();
});

Expand Down Expand Up @@ -339,11 +340,11 @@ describe('main.load', function() {
var stubs = [],
status_stub;

// generic empty callback function with ultramegasuper callback position detection
//generic empty callback function with ultramegasuper callback position detection
var fn = function() {
var cb;

// find callback in arguments
//find callback in arguments
for (var i = 0; i < arguments.length; i++) {
if (typeof arguments[i] == 'function')
cb = arguments[i];
Expand All @@ -353,7 +354,7 @@ describe('main.load', function() {
};

before(function() {
// first, reset the setup_stub defined at the start
//first, reset the setup_stub defined at the start
setup_stub.restore();
stubs.push(sinon.stub(setup, 'start').callsFake(fn));
stubs.push(sinon.stub(long_polling, 'load').callsFake(fn));
Expand Down Expand Up @@ -392,6 +393,7 @@ describe('main.load', function() {
var common_dup = {
hooks : hooks,
logger : common.logger,
system : common.system,
config : config,
commands : {
perform: sinon.spy(),
Expand Down Expand Up @@ -442,7 +444,7 @@ describe('main.load', function() {

call(function() {

// all stubs should have beenc called
//all stubs should have beenc called
stubs.forEach(function(s) {
s.called.should.be.true;
});
Expand All @@ -458,4 +460,4 @@ describe('main.load', function() {

});

});
});
141 changes: 0 additions & 141 deletions lib/agent/plugins/control-panel/test/secure.js

This file was deleted.

Loading