فهرست منبع

Add acceptance tests for directory deletion

Simon Detheridge 6 سال پیش
والد
کامیت
9f74aac1a0
1فایلهای تغییر یافته به همراه32 افزوده شده و 3 حذف شده
  1. 32 3
      services/filestore/test/acceptance/js/FilestoreTests.js

+ 32 - 3
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() {