From 0421e54b3e3a14f0e664aa1d8c251a784ba10883 Mon Sep 17 00:00:00 2001 From: williamlardier Date: Fri, 29 Nov 2024 13:43:47 +0100 Subject: [PATCH] Split the test It was not testing both cases, but only one Issue: ARSN-448 --- tests/unit/s3routes/routeDELETE.spec.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/unit/s3routes/routeDELETE.spec.js b/tests/unit/s3routes/routeDELETE.spec.js index a78e89ac5..30f84bd34 100644 --- a/tests/unit/s3routes/routeDELETE.spec.js +++ b/tests/unit/s3routes/routeDELETE.spec.js @@ -91,7 +91,7 @@ describe('routeDELETE', () => { ); }); - it('should return 204 when objectDelete encounters NoSuchKey or NoSuchVersion errors', () => { + it('should return 204 when objectDelete encounters NoSuchKey errors', () => { request.objectKey = 'objectKey'; request.query = {}; @@ -107,6 +107,22 @@ describe('routeDELETE', () => { ); }); + it('should return 204 when objectDelete encounters NoSuchVersion errors', () => { + request.objectKey = 'objectKey'; + request.query = {}; + + const noSuchVersionError = new ArsenalError('NoSuchVersion'); + api.callApiMethod = jest.fn((method, req, res, log, callback) => { + callback(noSuchVersionError, {}); + }); + + routeDELETE(request, response, api, log, statsClient); + + expect(routesUtils.responseNoBody).toHaveBeenCalledWith( + null, {}, response, 204, log, + ); + }); + it('should return error code when objectDelete encounters non-arsenal errors', () => { request.objectKey = 'objectKey'; request.query = {};