strip out unreachable releases
This commit is contained in:
parent
436aa41025
commit
0485323ffb
20
common.js
20
common.js
@ -1,7 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var path = require('path'),
|
var path = require('path'),
|
||||||
safe = require('safetydance');
|
safe = require('safetydance'),
|
||||||
|
_ = require('underscore');
|
||||||
|
|
||||||
exports = module.exports = {
|
exports = module.exports = {
|
||||||
TESTAPP_ID: 'io.cloudron.testapp',
|
TESTAPP_ID: 'io.cloudron.testapp',
|
||||||
@ -10,7 +11,8 @@ exports = module.exports = {
|
|||||||
cloudronDomain: cloudronDomain,
|
cloudronDomain: cloudronDomain,
|
||||||
verifyResponse: verifyResponse,
|
verifyResponse: verifyResponse,
|
||||||
getOwner: getOwner,
|
getOwner: getOwner,
|
||||||
stripeSecret: stripeSecret
|
stripeSecret: stripeSecret,
|
||||||
|
stripUnreachable: stripUnreachable
|
||||||
};
|
};
|
||||||
|
|
||||||
var gNow = ((new Date()).getTime() / 1000).toFixed();
|
var gNow = ((new Date()).getTime() / 1000).toFixed();
|
||||||
@ -20,6 +22,20 @@ function cloudronDomain(filename) {
|
|||||||
return 't-' + path.basename(filename, '-test.js') + '-' + gNow + '.smartserver.io';
|
return 't-' + path.basename(filename, '-test.js') + '-' + gNow + '.smartserver.io';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stripUnreachable(releases) {
|
||||||
|
var reachableVersions = [ ];
|
||||||
|
var curVersion = '0.0.1';
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
reachableVersions.push(curVersion);
|
||||||
|
var nextVersion = releases[curVersion].next;
|
||||||
|
if (!nextVersion) break;
|
||||||
|
curVersion = nextVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _.pick(releases, reachableVersions);
|
||||||
|
}
|
||||||
|
|
||||||
function verifyResponse(res, errorMessage) {
|
function verifyResponse(res, errorMessage) {
|
||||||
if (res.statusCode < 200 || res.statusCode > 299) {
|
if (res.statusCode < 200 || res.statusCode > 299) {
|
||||||
console.log('Response error statusCode:%s error:%s body:%s', res.statusCode, res.error, res.body);
|
console.log('Response error statusCode:%s error:%s body:%s', res.statusCode, res.error, res.body);
|
||||||
|
@ -41,10 +41,10 @@ describe('Cloudron update testing', function () {
|
|||||||
it('can query versions', function () {
|
it('can query versions', function () {
|
||||||
res = request.get('https://s3.amazonaws.com/staging-cloudron-releases/versions.json').end();
|
res = request.get('https://s3.amazonaws.com/staging-cloudron-releases/versions.json').end();
|
||||||
common.verifyResponse(res);
|
common.verifyResponse(res);
|
||||||
var boxVersions = Object.keys(res.body).sort(semver.rcompare);
|
var boxVersions = Object.keys(common.stripUnreachable(res.body)).sort(semver.rcompare);
|
||||||
fromVersion = boxVersions[2]; // we released a new version in before()
|
fromVersion = boxVersions[2]; // we released a new version in before()
|
||||||
toVersion = boxVersions[1];
|
toVersion = boxVersions[1];
|
||||||
nextVersion = semver.inc(toVersion, 'patch');
|
nextVersion = boxVersions[0];
|
||||||
|
|
||||||
console.log('Will test update from %s to %s', fromVersion.yellow, toVersion.yellow);
|
console.log('Will test update from %s to %s', fromVersion.yellow, toVersion.yellow);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user