Mholloway has uploaded a new change for review.
https://gerrit.wikimedia.org/r/297332
Change subject: Ensure that tests for errors enforce an error response
......................................................................
Ensure that tests for errors enforce an error response
Prior to Iac1d48ffaf381947f8a662585a3cdba9a70b3fa8, there were tests
that should have been failing but passed because they were receiving
a 200 response and the tests did not contain a check to ensure that
the response was in fact an error. This adds such checks.
Change-Id: Ib776e5593cd6aa6fd108a672cc81bf06317940e6
Depends-On: Iac1d48ffaf381947f8a662585a3cdba9a70b3fa8
---
M test/features/definition/definition.js
M test/features/featured-image/pagecontent.js
M test/features/featured/pagecontent.js
3 files changed, 8 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps
refs/changes/32/297332/1
diff --git a/test/features/definition/definition.js
b/test/features/definition/definition.js
index 887f527..2f3aaa7 100644
--- a/test/features/definition/definition.js
+++ b/test/features/definition/definition.js
@@ -41,7 +41,7 @@
it('missing definitions', function() {
return preq.get({ uri: server.config.uri +
'en.wiktionary.org/v1/page/definition/Dssjbkrt' })
.then(function(res) {
- assert.status(res, 404);
+ throw new Error('Expected an error, but got status: ' +
res.status);
}, function(err) {
assert.status(err, 404);
});
@@ -50,7 +50,7 @@
it('non-term page', function() {
return preq.get({ uri: server.config.uri +
'en.wiktionary.org/v1/page/definition/Main_page' })
.then(function(res) {
- assert.status(res, 404);
+ throw new Error('Expected an error, but got status: ' +
res.status);
}, function(err) {
assert.status(err, 404);
});
@@ -59,7 +59,7 @@
it('unsupported language', function() {
return preq.get({ uri: server.config.uri +
'ru.wiktionary.org/v1/page/definition/Baba' })
.then(function(res) {
- assert.status(res, 501);
+ throw new Error('Expected an error, but got status: ' +
res.status);
}, function(err) {
assert.status(err, 501);
});
diff --git a/test/features/featured-image/pagecontent.js
b/test/features/featured-image/pagecontent.js
index 1ad06b2..9c8ddfb 100644
--- a/test/features/featured-image/pagecontent.js
+++ b/test/features/featured-image/pagecontent.js
@@ -52,7 +52,7 @@
.then(function(res) {
assert.ok(res.body.description.text.indexOf('Main altar') >=
0);
assert.equal(res.body.description.lang, 'en');
- });
+ });
});
it('featured image of an old date should return 404', function() {
diff --git a/test/features/featured/pagecontent.js
b/test/features/featured/pagecontent.js
index 7bcc4d3..da173e7 100644
--- a/test/features/featured/pagecontent.js
+++ b/test/features/featured/pagecontent.js
@@ -41,6 +41,7 @@
it('incomplete date should return 404', function() {
return preq.get({ uri: server.config.uri +
'en.wikipedia.org/v1/page/featured/2016/04' })
.then(function(res) {
+ throw new Error('Expected an error, but got status: ' +
res.status);
}, function(err) {
assert.status(err, 404);
});
@@ -49,6 +50,7 @@
it('extra uri path parameter after date should return 404', function() {
return preq.get({ uri: server.config.uri +
'en.wikipedia.org/v1/page/featured/2016/04/15/11' })
.then(function(res) {
+ throw new Error('Expected an error, but got status: ' +
res.status);
}, function(err) {
assert.status(err, 404);
});
@@ -57,6 +59,7 @@
it('unsupported language', function() {
return preq.get({ uri: server.config.uri +
'fr.wikipedia.org/v1/page/featured/2016/04/15' })
.then(function(res) {
+ throw new Error('Expected an error, but got status: ' +
res.status);
}, function(err) {
assert.status(err, 501);
assert.equal(err.body.type, 'unsupported_language');
@@ -66,6 +69,7 @@
it('featured article of an old date should return 404', function() {
return preq.get({ uri: server.config.uri +
'en.wikipedia.org/v1/page/featured/1970/12/31' })
.then(function(res) {
+ throw new Error('Expected an error, but got status: ' +
res.status);
}, function(err) {
assert.status(err, 404);
assert.equal(err.body.type, 'not_found');
--
To view, visit https://gerrit.wikimedia.org/r/297332
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib776e5593cd6aa6fd108a672cc81bf06317940e6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Mholloway <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits