From d44cfb8614eefffc7f5b1a4558215b2b22ac6325 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Wed, 9 Sep 2015 09:44:38 +0100 Subject: [PATCH] added test to check compile should continue on error downloading http resource also improved logging --- services/clsi/app/coffee/ResourceWriter.coffee | 2 +- services/clsi/test/unit/coffee/ResourceWriterTests.coffee | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/services/clsi/app/coffee/ResourceWriter.coffee b/services/clsi/app/coffee/ResourceWriter.coffee index faeaf1194e..25b2625f19 100644 --- a/services/clsi/app/coffee/ResourceWriter.coffee +++ b/services/clsi/app/coffee/ResourceWriter.coffee @@ -58,7 +58,7 @@ module.exports = ResourceWriter = if resource.url? UrlCache.downloadUrlToFile project_id, resource.url, path, resource.modified, (err)-> if err? - logger.err err:err, "error downloading file for resources" + logger.err err:err, project_id:project_id, path:path, resource_url:resource.url, modified:resource.modified, "error downloading file for resources" callback() #try and continue compiling even if http resource can not be downloaded at this time else fs.writeFile path, resource.content, callback diff --git a/services/clsi/test/unit/coffee/ResourceWriterTests.coffee b/services/clsi/test/unit/coffee/ResourceWriterTests.coffee index 1e7b3e776b..3e87b5ca34 100644 --- a/services/clsi/test/unit/coffee/ResourceWriterTests.coffee +++ b/services/clsi/test/unit/coffee/ResourceWriterTests.coffee @@ -1,6 +1,6 @@ SandboxedModule = require('sandboxed-module') sinon = require('sinon') -require('chai').should() +should = require('chai').should() modulePath = require('path').join __dirname, '../../../app/js/ResourceWriter' path = require "path" @@ -94,7 +94,7 @@ describe "ResourceWriter", -> path: "main.tex" url: "http://www.example.com/main.tex" modified: Date.now() - @UrlCache.downloadUrlToFile = sinon.stub().callsArg(4) + @UrlCache.downloadUrlToFile = sinon.stub().callsArgWith(4, "fake error downloading file") @ResourceWriter._writeResourceToDisk(@project_id, @resource, @basePath, @callback) it "should ensure the directory exists", -> @@ -110,6 +110,9 @@ describe "ResourceWriter", -> it "should call the callback", -> @callback.called.should.equal true + it "should not return an error if the resource writer errored", -> + should.not.exist @callback.args[0][0] + describe "with a content based resource", -> beforeEach -> @resource =