From a69da13884f8a5b4d071554ec0dca44bf4dd9708 Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Sun, 2 Jun 2024 17:48:37 +0200 Subject: [PATCH] replace res.sendStatus with res.status and update tests --- lib/handlers/patch.js | 4 ++-- test/integration/acl-oidc-test.js | 4 ++-- test/integration/patch-sparql-update-test.js | 2 +- test/integration/patch-test.js | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/handlers/patch.js b/lib/handlers/patch.js index 04bcba1e7..481027fdf 100644 --- a/lib/handlers/patch.js +++ b/lib/handlers/patch.js @@ -91,8 +91,8 @@ async function patchHandler (req, res, next) { return writeGraph(graph, resource, ldp.resourceMapper.resolveFilePath(req.hostname), ldp.serverUri) }) - // Send the result to the client - res.sendStatus(resourceExists ? 200 : 201) + // Send the status and result to the client + res.status(resourceExists ? 200 : 201) res.send(result) } catch (err) { return next(err) diff --git a/test/integration/acl-oidc-test.js b/test/integration/acl-oidc-test.js index 77919a350..a5a31270b 100644 --- a/test/integration/acl-oidc-test.js +++ b/test/integration/acl-oidc-test.js @@ -557,7 +557,7 @@ describe('ACL with WebID+OIDC over HTTP', function () { options.headers['content-type'] = 'application/sparql-update' request.patch(options, function (error, response, body) { assert.equal(error, null) - assert.equal(response.statusCode, 200) + assert.equal(response.statusCode, 201) done() }) }) @@ -616,7 +616,7 @@ describe('ACL with WebID+OIDC over HTTP', function () { options.headers['content-type'] = 'application/sparql-update' request.patch(options, function (error, response, body) { assert.equal(error, null) - assert.equal(response.statusCode, 200) + assert.equal(response.statusCode, 201) done() }) }) diff --git a/test/integration/patch-sparql-update-test.js b/test/integration/patch-sparql-update-test.js index 3e8a1ad21..69ea9b010 100644 --- a/test/integration/patch-sparql-update-test.js +++ b/test/integration/patch-sparql-update-test.js @@ -22,7 +22,7 @@ describe('PATCH through application/sparql-update', function () { server.patch('/notExisting.ttl') .set('content-type', 'application/sparql-update') .send('INSERT DATA { :test :hello 456 .}') - .expect(200) + .expect(201) .end(function (err, res, body) { assert.equal( read('sampleContainer/notExisting.ttl'), diff --git a/test/integration/patch-test.js b/test/integration/patch-test.js index 846f04801..9d3d6f133 100644 --- a/test/integration/patch-test.js +++ b/test/integration/patch-test.js @@ -79,7 +79,7 @@ describe('PATCH through text/n3', () => { patch: `<> a solid:InsertDeletePatch; solid:inserts { . }.` }, { // expected: - status: 200, + status: 201, text: 'Patch applied successfully', result: '@prefix : .\n@prefix tim: .\n\ntim:x tim:y tim:z.\n\n' })) @@ -90,7 +90,7 @@ describe('PATCH through text/n3', () => { patch: `<> a solid:InsertDeletePatch; solid:inserts { . }.` }, { // expected: - status: 200, + status: 201, text: 'Patch applied successfully', // result: '{\n "@id": "/x",\n "/y": {\n "@id": "/z"\n }\n}' result: `{ @@ -110,7 +110,7 @@ describe('PATCH through text/n3', () => { patch: `<> a solid:InsertDeletePatch; solid:inserts { . }.` }, { // expected: - status: 200, + status: 201, text: 'Patch applied successfully', result: ` { patch: `<> a solid:InsertDeletePatch; solid:inserts { . }.` }, { // expected: - status: 200, + status: 201, text: 'Patch applied successfully', result: '@prefix : .\n@prefix tim: .\n\ntim:x tim:y tim:z.\n\n' })) @@ -186,7 +186,7 @@ describe('PATCH through text/n3', () => { patch: `<> a solid:InsertDeletePatch; solid:inserts { . }.` }, { - status: 200, + status: 201, text: 'Patch applied successfully', result: '@prefix : <#>.\n@prefix fol: <./>.\n\nfol:x fol:y fol:z.\n\n' }))