aboutsummaryrefslogtreecommitdiffstats
path: root/cucumber-js-test-apis-ci
diff options
context:
space:
mode:
Diffstat (limited to 'cucumber-js-test-apis-ci')
-rw-r--r--cucumber-js-test-apis-ci/cucumber-common/utils/Utils.js51
-rw-r--r--cucumber-js-test-apis-ci/docker_run.sh3
2 files changed, 31 insertions, 23 deletions
diff --git a/cucumber-js-test-apis-ci/cucumber-common/utils/Utils.js b/cucumber-js-test-apis-ci/cucumber-common/utils/Utils.js
index 22ee775080..ed16d8bbf4 100644
--- a/cucumber-js-test-apis-ci/cucumber-common/utils/Utils.js
+++ b/cucumber-js-test-apis-ci/cucumber-common/utils/Utils.js
@@ -76,6 +76,7 @@ function _requestRest(context, method, path, data, type) {
return _request(context, method, path, options);
}
+
function _request(context, method, path, options) {
console.log('--> Calling REST ' + options.method +' url: ' + options.url);
let inputData = options.json;
@@ -94,36 +95,44 @@ function _request(context, method, path, options) {
return needle(method, options.url, inputData, needleOptions)
.then(function(result) {
context.inputData = null;
- let isExpected = (context.shouldFail) ? (result.statusCode != 200 && result.statusCode != 201) : (result.statusCode == 200 || result.statusCode == 201);
+ let successResult = result.statusCode >= 200 && result.statusCode < 300;
+ let isExpected = context.shouldFail ? !successResult : successResult;
data = result.body;
if (!isExpected) {
console.log('Did not get expected response code');
throw 'Status Code was ' + result.statusCode ;
}
- if (context.shouldFail && context.errorCode) {
- if (typeof data === 'string' && data) {
- data = JSON.parse(data);
- }
- let errorCode = data.errorCode;
- let contextErrorCode = context.errorCode;
- context.errorCode = null;
- if (errorCode !== contextErrorCode) {
- throw 'Error Code was ' + errorCode + ' instead of ' + contextErrorCode;
- }
- }
- if (context.shouldFail && context.errorMessage) {
- if (typeof data === 'string' && data) {
- data = JSON.parse(data);
- }
- let errorMessage = data.message;
- let contextErrorMessage = context.errorMessage;
- context.errorMessage = null;
- if (errorMessage !== contextErrorMessage) {
- throw 'Error Message was ' + errorMessage + ' instead of ' + contextErrorMessage;
+ if (context.statusCode) {
+ let expectedStatusCode = context.statusCode;
+ context.statusCode = null;
+ if (result.statusCode !== expectedStatusCode) {
+ throw 'Response Status Code was ' + result.statusCode + ' instead of ' + expectedStatusCode;
}
}
if (context.shouldFail) {
context.shouldFail = false;
+ if (context.errorCode) {
+ if (typeof data === 'string' && data) {
+ data = JSON.parse(data);
+ }
+ let contextErrorCode = context.errorCode;
+ let errorCode = data.errorCode;
+ context.errorCode = null;
+ if (errorCode !== contextErrorCode) {
+ throw 'Error Code was ' + errorCode + ' instead of ' + contextErrorCode;
+ }
+ }
+ if (context.errorMessage) {
+ if (typeof data === 'string' && data) {
+ data = JSON.parse(data);
+ }
+ let errorMessage = data.message;
+ let contextErrorMessage = context.errorMessage;
+ context.errorMessage = null;
+ if (errorMessage !== contextErrorMessage) {
+ throw 'Error Message was ' + errorMessage + ' instead of ' + contextErrorMessage;
+ }
+ }
return({statusCode: result.statusCode, data: {}});
}
diff --git a/cucumber-js-test-apis-ci/docker_run.sh b/cucumber-js-test-apis-ci/docker_run.sh
index 95cdab302a..045162ace7 100644
--- a/cucumber-js-test-apis-ci/docker_run.sh
+++ b/cucumber-js-test-apis-ci/docker_run.sh
@@ -13,7 +13,7 @@ then
fi
if [ -z "$IMAGES_TAG" ]
then
- IMAGES_TAG=1.4-STAGING-latest
+ IMAGES_TAG=1.5-STAGING-latest
fi
fi
echo "Workspace under: $WORKSPACE"
@@ -54,7 +54,6 @@ mv $WORKSPACE/TEST_CI.json $WORKSPACE/data/environments
sed -i "s/8080:8080/$TEST_CI_CATALOG_PORT:8080/g" $WORKSPACE/data/scripts/docker_run.sh
sed -i "s/:8080\/sdc/:$TEST_CI_CATALOG_PORT\/sdc/g" $WORKSPACE/data/scripts/docker_run.sh
-
echo "getting images for $IMAGES_TAG"
$WORKSPACE/data/scripts/docker_run.sh -e TEST_CI -r $IMAGES_TAG -p 10001