Skip to content

Commit

Permalink
Update check update to match new format returned by barracks
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregoire Weber committed Mar 24, 2017
1 parent f6dc117 commit 87bdc28
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 227 deletions.
2 changes: 1 addition & 1 deletion example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var barracks = new Barracks({
downloadFilePath: '/tmp/file.tmp'
});

fucntion donwloadPackages(packages) {
function donwloadPackages(packages) {
var promises = packages.map(function (package) {
return package.download('/tmp/' + package.package + '_' + package.version + '_' + package.filename);
});
Expand Down
21 changes: 0 additions & 21 deletions src/clientHelper.js

This file was deleted.

3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var CHECK_UPDATE_ENDPOINT = '/api/device/v2/update/check';
require('es6-promise').polyfill();
var fs = require('fs');
var request = require('request');
var clientHelper = require('./clientHelper');
var fileHelper = require('./fileHelper');

function Barracks(options) {
Expand Down Expand Up @@ -50,7 +49,7 @@ Barracks.prototype.checkUpdate = function (packages, customClientData) {
message: 'Check Update request failed: ' + error.message
});
} else if (response.statusCode == 200) {
resolve(clientHelper.buildCheckUpdateResult(JSON.parse(body), that));
resolve(JSON.parse(body));
} else {
reject({
type: ERROR_UNEXPECTED_SERVER_RESPONSE,
Expand Down
183 changes: 0 additions & 183 deletions tests/clientHelper_test.js

This file was deleted.

20 changes: 0 additions & 20 deletions tests/index_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ describe('checkUpdate(components, customClientData) ', function () {

var barracks;
var requestMock = function () {};
var buildCheckUpdateResultMock = function () {};

function getRequestPayloadForComponents(components) {
return {
Expand All @@ -130,11 +129,6 @@ describe('checkUpdate(components, customClientData) ', function () {
var Barracks = proxyquire('../src/index.js', {
'request': function (options, callback) {
return requestMock(options, callback);
},
'./clientHelper': {
buildCheckUpdateResult: function (response) {
return buildCheckUpdateResultMock(response);
}
}
});

Expand Down Expand Up @@ -217,11 +211,6 @@ describe('checkUpdate(components, customClientData) ', function () {
requestSpy(options, callback);
callback(undefined, response, response.body);
};
var buildCheckUpdateResultSpy = sinon.spy();
buildCheckUpdateResultMock = function (response) {
buildCheckUpdateResultSpy(response);
return response;
};

// When / Then
barracks.checkUpdate(components).then(function (result) {
Expand All @@ -231,8 +220,6 @@ describe('checkUpdate(components, customClientData) ', function () {
getRequestPayloadForComponents(components),
sinon.match.func
);
expect(buildCheckUpdateResultSpy).to.have.been.calledOnce;
expect(buildCheckUpdateResultSpy).to.have.been.calledWithExactly(componentInfo);
done();
}).catch(function (err) {
done(err);
Expand All @@ -257,11 +244,6 @@ describe('checkUpdate(components, customClientData) ', function () {
requestSpy(options, callback);
callback(undefined, response, response.body);
};
var buildCheckUpdateResultSpy = sinon.spy();
buildCheckUpdateResultMock = function (response) {
buildCheckUpdateResultSpy(response);
return response;
};

// When / Then
barracks.checkUpdate(components).then(function (result) {
Expand All @@ -271,8 +253,6 @@ describe('checkUpdate(components, customClientData) ', function () {
getRequestPayloadForComponents(components),
sinon.match.func
);
expect(buildCheckUpdateResultSpy).to.have.been.calledOnce;
expect(buildCheckUpdateResultSpy).to.have.been.calledWithExactly(componentInfo);
done();
}).catch(function (err) {
done(err);
Expand Down

0 comments on commit 87bdc28

Please sign in to comment.