ソースを参照

added delete accp test

Henry Oswald 12 年 前
親
コミット
5d00f70a31

+ 20 - 7
services/filestore/test/acceptence/coffee/SendingFileTest.coffee

@@ -26,7 +26,7 @@ describe "Sending a file", ->
 		@filestoreUrl = "http://localhost:#{settings.internal.filestore.port}"
 		@filestoreUrl = "http://localhost:#{settings.internal.filestore.port}"
 
 
 	beforeEach (done)->
 	beforeEach (done)->
-		fs.unlink @localFileWritePath, ->
+		fs.unlink @localFileWritePath, =>
 			done()
 			done()
 
 
 
 
@@ -38,18 +38,31 @@ describe "Sending a file", ->
 			body.indexOf("up").should.not.equal -1
 			body.indexOf("up").should.not.equal -1
 			done()
 			done()
 
 
-	it "should be able get the file back", (done)->
-		@timeout(1000 * 10)
-		@fileUrl = "#{@filestoreUrl}/project/acceptence_tests/file/12345"
+	describe "with a file on the server", ->
 
 
-		writeStream = request.post(@fileUrl)
+		beforeEach (done)->
+			@timeout(1000 * 5)
+			@fileUrl = "#{@filestoreUrl}/project/acceptence_tests/file/#{Math.random()}"
 
 
-		writeStream.on "end", =>
+			writeStream = request.post(@fileUrl)
+
+			writeStream.on "end", =>
+				done()
+			fs.createReadStream(@localFileReadPath).pipe writeStream
+
+		it "should be able get the file back", (done)->
+			@timeout(1000 * 10)
 			request.get @fileUrl, (err, response, body)=>
 			request.get @fileUrl, (err, response, body)=>
 				body.should.equal @constantFileContent
 				body.should.equal @constantFileContent
 				done()
 				done()
 
 
-		fs.createReadStream(@localFileReadPath).pipe writeStream
+		it "should be able to delete the file", (done)->
+			request.del @fileUrl, (err, response, body)=>
+				response.statusCode.should.equal 204
+				request.get @fileUrl, (err, response, body)=>
+					body.indexOf("NoSuchKey").should.not.equal -1
+					done()
+