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 broken unit test due to recent changes in iotagent-node-lib module #313

Merged
merged 1 commit into from
Dec 5, 2018
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
7 changes: 4 additions & 3 deletions test/unit/amqpBinding-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var iotagentMqtt = require('../../'),
amqp = require('amqplib/callback_api'),
apply = async.apply,
contextBrokerMock,
contextBrokerUnprovMock,
amqpConn,
channel;

Expand Down Expand Up @@ -118,14 +119,14 @@ describe('AMQP Transport binding: measures', function() {
};

beforeEach(function(done) {
contextBrokerMock = nock('http://192.168.1.1:1026')
contextBrokerUnprovMock = nock('http://unexistentHost:1026')
.matchHeader('fiware-service', 'TestService')
.matchHeader('fiware-servicepath', '/testingPath')
.post('/v1/updateContext')
.reply(200, utils.readExampleFile('./test/contextResponses/multipleMeasuresSuccess.json'));


contextBrokerMock
contextBrokerUnprovMock
.matchHeader('fiware-service', 'TestService')
.matchHeader('fiware-servicepath', '/testingPath')
.post('/v1/updateContext', utils.readExampleFile('./test/contextRequests/unprovisionedMeasure.json'))
Expand All @@ -140,7 +141,7 @@ describe('AMQP Transport binding: measures', function() {
channel.publish(config.amqp.exchange, '.80K09H324HV8732.MQTT_UNPROVISIONED.attrs.a', new Buffer('23'));

setTimeout(function() {
contextBrokerMock.done();
contextBrokerUnprovMock.done();
done();
}, 100);
});
Expand Down
7 changes: 4 additions & 3 deletions test/unit/httpBinding-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var iotagentUl = require('../../'),
request = require('request'),
utils = require('../utils'),
contextBrokerMock,
contextBrokerUnprovMock,
iotamMock;

describe('HTTP Transport binding: measures', function() {
Expand Down Expand Up @@ -139,14 +140,14 @@ describe('HTTP Transport binding: measures', function() {
};

beforeEach(function(done) {
contextBrokerMock = nock('http://192.168.1.1:1026')
contextBrokerUnprovMock = nock('http://unexistentHost:1026')
.matchHeader('fiware-service', 'TestService')
.matchHeader('fiware-servicepath', '/testingPath')
.post('/v1/updateContext')
.reply(200, utils.readExampleFile('./test/contextResponses/multipleMeasuresSuccess.json'));


contextBrokerMock
contextBrokerUnprovMock
.matchHeader('fiware-service', 'TestService')
.matchHeader('fiware-servicepath', '/testingPath')
.post('/v1/updateContext', utils.readExampleFile('./test/contextRequests/unprovisionedMeasure.json'))
Expand All @@ -166,7 +167,7 @@ describe('HTTP Transport binding: measures', function() {
});
it('should send a new update context request to the Context Broker with just that attribute', function(done) {
request(getOptions, function(error, response, body) {
contextBrokerMock.done();
contextBrokerUnprovMock.done();
done();
});
});
Expand Down
7 changes: 4 additions & 3 deletions test/unit/mqttBinding-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var iotagentMqtt = require('../../'),
request = require('request'),
utils = require('../utils'),
contextBrokerMock,
contextBrokerUnprovMock,
mqttClient;

describe('MQTT Transport binding: measures', function() {
Expand Down Expand Up @@ -107,14 +108,14 @@ describe('MQTT Transport binding: measures', function() {
};

beforeEach(function(done) {
contextBrokerMock = nock('http://192.168.1.1:1026')
contextBrokerUnprovMock = nock('http://unexistentHost:1026')
.matchHeader('fiware-service', 'TestService')
.matchHeader('fiware-servicepath', '/testingPath')
.post('/v1/updateContext')
.reply(200, utils.readExampleFile('./test/contextResponses/multipleMeasuresSuccess.json'));


contextBrokerMock
contextBrokerUnprovMock
.matchHeader('fiware-service', 'TestService')
.matchHeader('fiware-servicepath', '/testingPath')
.post('/v1/updateContext', utils.readExampleFile('./test/contextRequests/unprovisionedMeasure.json'))
Expand All @@ -128,7 +129,7 @@ describe('MQTT Transport binding: measures', function() {
it('should send a new update context request to the Context Broker with just that attribute', function(done) {
mqttClient.publish('/80K09H324HV8732/MQTT_UNPROVISIONED/attrs/a', '23', null, function(error) {
setTimeout(function() {
contextBrokerMock.done();
contextBrokerUnprovMock.done();
done();
}, 100);
});
Expand Down
7 changes: 4 additions & 3 deletions test/unit/ngsiv2/amqpBinding-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var iotagentUl = require('../../../'),
amqp = require('amqplib/callback_api'),
apply = async.apply,
contextBrokerMock,
contextBrokerUnprovMock,
amqpConn,
channel;

Expand Down Expand Up @@ -127,14 +128,14 @@ describe('AMQP Transport binding: measures', function() {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
contextBrokerUnprovMock = nock('http://unexistentHost:1026')
.matchHeader('fiware-service', 'TestService')
.matchHeader('fiware-servicepath', '/testingPath')
.post('/v2/entities?options=upsert')
.reply(204);


contextBrokerMock
contextBrokerUnprovMock
.matchHeader('fiware-service', 'TestService')
.matchHeader('fiware-servicepath', '/testingPath')
.post('/v2/entities/SensorMachine:UL_UNPROVISIONED/attrs',
Expand All @@ -151,7 +152,7 @@ describe('AMQP Transport binding: measures', function() {
new Buffer('23'));

setTimeout(function() {
contextBrokerMock.done();
contextBrokerUnprovMock.done();
done();
}, 100);
});
Expand Down
7 changes: 4 additions & 3 deletions test/unit/ngsiv2/httpBindings-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var iotagentUl = require('../../../'),
async = require('async'),
request = require('request'),
utils = require('../../utils'),
contextBrokerUnprovMock,
contextBrokerMock,
iotamMock;

Expand Down Expand Up @@ -188,13 +189,13 @@ describe('HTTP Transport binding: measures', function() {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
contextBrokerUnprovMock = nock('http://unexistentHost:1026')
.matchHeader('fiware-service', 'TestService')
.matchHeader('fiware-servicepath', '/testingPath')
.post('/v2/entities?options=upsert')
.reply(204);

contextBrokerMock = nock('http://192.168.1.1:1026')
contextBrokerUnprovMock
.matchHeader('fiware-service', 'TestService')
.matchHeader('fiware-servicepath', '/testingPath')
.post('/v2/entities/SensorMachine:UL_UNPROVISIONED/attrs',
Expand All @@ -215,7 +216,7 @@ describe('HTTP Transport binding: measures', function() {
});
it('should send a new update context request to the Context Broker with just that attribute', function(done) {
request(getOptions, function(error, response, body) {
contextBrokerMock.done();
contextBrokerUnprovMock.done();
done();
});
});
Expand Down
7 changes: 4 additions & 3 deletions test/unit/ngsiv2/mqttBinding-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var iotagentUL = require('../../../'),
request = require('request'),
utils = require('../../utils'),
contextBrokerMock,
contextBrokerUnprovMock,
mqttClient;


Expand Down Expand Up @@ -143,14 +144,14 @@ describe('MQTT Transport binding: measures', function() {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
contextBrokerUnprovMock = nock('http://unexistentHost:1026')
.matchHeader('fiware-service', 'TestService')
.matchHeader('fiware-servicepath', '/testingPath')
.post('/v2/entities?options=upsert')
.reply(204);


contextBrokerMock
contextBrokerUnprovMock
.matchHeader('fiware-service', 'TestService')
.matchHeader('fiware-servicepath', '/testingPath')
.post('/v2/entities/SensorMachine:UL_UNPROVISIONED/attrs',
Expand All @@ -165,7 +166,7 @@ describe('MQTT Transport binding: measures', function() {
it('should send a new update context request to the Context Broker with just that attribute', function(done) {
mqttClient.publish('/80K09H324HV8732/UL_UNPROVISIONED/attrs/temperature', '23', null, function(error) {
setTimeout(function() {
contextBrokerMock.done();
contextBrokerUnprovMock.done();
done();
}, 100);
});
Expand Down