From 9f74aac1a08fcb099ef3ebe98115d8f0710e0488 Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Mon, 16 Mar 2020 11:34:45 +0000 Subject: [PATCH] Add acceptance tests for directory deletion --- .../test/acceptance/js/FilestoreTests.js | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/services/filestore/test/acceptance/js/FilestoreTests.js b/services/filestore/test/acceptance/js/FilestoreTests.js index 8369698891..dc31d1a83c 100644 --- a/services/filestore/test/acceptance/js/FilestoreTests.js +++ b/services/filestore/test/acceptance/js/FilestoreTests.js @@ -252,7 +252,7 @@ describe('Filestore', function() { }) describe('with multiple files', function() { - let fileIds, fileUrls + let fileIds, fileUrls, projectUrl const localFileReadPaths = [ '/tmp/filestore_acceptance_tests_file_read_1.txt', '/tmp/filestore_acceptance_tests_file_read_2.txt' @@ -278,10 +278,11 @@ describe('Filestore', function() { }) beforeEach(async function() { + projectUrl = `${filestoreUrl}/project/${projectId}` fileIds = [ObjectId().toString(), ObjectId().toString()] fileUrls = [ - `${filestoreUrl}/project/${projectId}/file/${fileIds[0]}`, - `${filestoreUrl}/project/${projectId}/file/${fileIds[1]}` + `${projectUrl}/file/${fileIds[0]}`, + `${projectUrl}/file/${fileIds[1]}` ] const writeStreams = [ @@ -311,6 +312,34 @@ describe('Filestore', function() { constantFileContents[0].length + constantFileContents[1].length ) }) + + it('should store the files', async function() { + for (const index in fileUrls) { + await expect(rp.get(fileUrls[index])).to.eventually.have.property( + 'body', + constantFileContents[index] + ) + } + }) + + it('should be able to delete the project', async function() { + await expect(rp.delete(projectUrl)).to.eventually.have.property( + 'statusCode', + 204 + ) + + for (const index in fileUrls) { + await expect( + rp.get(fileUrls[index]) + ).to.eventually.be.rejected.and.have.property('statusCode', 404) + } + }) + + it('should not delete a partial project id', async function() { + await expect( + rp.delete(`${filestoreUrl}/project/5`) + ).to.eventually.be.rejected.and.have.property('statusCode', 400) + }) }) describe('with a large file', function() {