From b09ce6455f8e2bf9dd741532e6ad09309880ff74 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Jan 2017 11:55:31 +0100 Subject: Server: error if we add a pod that already exists --- server/tests/api/check-params/pods.js | 8 ++++++++ server/tests/utils/requests.js | 11 ++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'server/tests') diff --git a/server/tests/api/check-params/pods.js b/server/tests/api/check-params/pods.js index 2f85af644..8d52b69b1 100644 --- a/server/tests/api/check-params/pods.js +++ b/server/tests/api/check-params/pods.js @@ -189,6 +189,14 @@ describe('Test pods API validators', function () { } requestsUtils.makePostBodyRequest(server.url, path, null, data, done, 200) }) + + it('Should fail with a host that already exists', function (done) { + const data = { + host: 'coucou.com', + publicKey: 'mysuperpublickey' + } + requestsUtils.makePostBodyRequest(server.url, path, null, data, done, 409) + }) }) after(function (done) { diff --git a/server/tests/utils/requests.js b/server/tests/utils/requests.js index b1470814d..84cf3483f 100644 --- a/server/tests/utils/requests.js +++ b/server/tests/utils/requests.js @@ -36,7 +36,8 @@ function makePostUploadRequest (url, path, token, fields, attaches, done, status req.attach(attach, value) }) - req.expect(statusCodeExpected, done) + req.expect(statusCodeExpected) + .end(done) } function makePostBodyRequest (url, path, token, fields, done, statusCodeExpected) { @@ -48,7 +49,9 @@ function makePostBodyRequest (url, path, token, fields, done, statusCodeExpected if (token) req.set('Authorization', 'Bearer ' + token) - req.send(fields).expect(statusCodeExpected, done) + req.send(fields) + .expect(statusCodeExpected) + .end(done) } function makePutBodyRequest (url, path, token, fields, done, statusCodeExpected) { @@ -60,7 +63,9 @@ function makePutBodyRequest (url, path, token, fields, done, statusCodeExpected) if (token) req.set('Authorization', 'Bearer ' + token) - req.send(fields).expect(statusCodeExpected, done) + req.send(fields) + .expect(statusCodeExpected) + .end(done) } // --------------------------------------------------------------------------- -- cgit v1.2.3