فهرست منبع

fix unit tests

Brian Gough 9 سال پیش
والد
کامیت
fdffc92de2

+ 3 - 3
services/web/test/UnitTests/coffee/Compile/ClsiManagerTests.coffee

@@ -247,12 +247,12 @@ describe "ClsiManager", ->
 					.calledWith(@project_id, {compiler:1, rootDoc_id: 1, imageName: 1, rootFolder: 1})
 					.should.equal true
 
-			it "should flush the project to the database", ->
+			it "should not explicitly flush the project to the database", ->
 				@DocumentUpdaterHandler.flushProjectToMongo
 					.calledWith(@project_id)
-					.should.equal true
+					.should.equal false
 
-			it "should get only the live docs from the docupdater", ->
+			it "should get only the live docs from the docupdater with a background flush in docupdater", ->
 				@DocumentUpdaterHandler.getProjectDocsIfMatch
 					.calledWith(@project_id)
 					.should.equal true

+ 7 - 7
services/web/test/UnitTests/coffee/DocumentUpdater/DocumentUpdaterHandlerTests.coffee

@@ -265,19 +265,19 @@ describe 'DocumentUpdaterHandler', ->
 					v: @version
 				@docs = [ @doc0, @doc0, @doc0 ]
 				@body = JSON.stringify @docs
-				@request.get = sinon.stub().callsArgWith(1, null, {statusCode: 200}, @body)
+				@request.post = sinon.stub().callsArgWith(1, null, {statusCode: 200}, @body)
 				@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
 
 			it 'should get the documenst from the document updater', ->
-				url = "#{@settings.apis.documentupdater.url}/project/#{@project_id}/doc?state=#{@project_state_hash}"
-				@request.get.calledWith(url).should.equal true
+				url = "#{@settings.apis.documentupdater.url}/project/#{@project_id}/get_and_flush_if_old?state=#{@project_state_hash}"
+				@request.post.calledWith(url).should.equal true
 
 			it "should call the callback with the documents", ->
 				@callback.calledWithExactly(null, @docs).should.equal true
 
 		describe "when the document updater API returns an error", ->
 			beforeEach ->
-				@request.get = sinon.stub().callsArgWith(1, @error = new Error("something went wrong"), null, null)
+				@request.post = sinon.stub().callsArgWith(1, @error = new Error("something went wrong"), null, null)
 				@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
 
 			it "should return an error to the callback", ->
@@ -285,7 +285,7 @@ describe 'DocumentUpdaterHandler', ->
 
 		describe "when the document updater returns a conflict error code", ->
 			beforeEach ->
-				@request.get = sinon.stub().callsArgWith(1, null, { statusCode: 409 }, "Conflict")
+				@request.post = sinon.stub().callsArgWith(1, null, { statusCode: 409 }, "Conflict")
 				@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
 
 			it "should return the callback with no documents", ->
@@ -312,7 +312,7 @@ describe 'DocumentUpdaterHandler', ->
 
 		describe "when the document updater API returns an error", ->
 			beforeEach ->
-				@request.get = sinon.stub().callsArgWith(1, @error = new Error("something went wrong"), null, null)
+				@request.post = sinon.stub().callsArgWith(1, @error = new Error("something went wrong"), null, null)
 				@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
 
 			it "should return an error to the callback", ->
@@ -320,7 +320,7 @@ describe 'DocumentUpdaterHandler', ->
 
 		describe "when the document updater returns a conflict error code", ->
 			beforeEach ->
-				@request.get = sinon.stub().callsArgWith(1, null, { statusCode: 409 }, "Conflict")
+				@request.post = sinon.stub().callsArgWith(1, null, { statusCode: 409 }, "Conflict")
 				@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
 
 			it "should return the callback with no documents", ->