basic acceptence test of sending and getting file back added

This commit is contained in:
Henry Oswald 2014-06-19 17:07:50 +01:00
parent 04bffaeceb
commit f83ab25b35
5 changed files with 76 additions and 12 deletions

View file

@ -19,6 +19,14 @@ module.exports = (grunt) ->
ext: '.js'
server_tests:
expand: true,
flatten: false,
cwd: 'test/acceptence/coffee',
src: ['*.coffee', '**/*.coffee'],
dest: 'test/acceptence/js/',
ext: '.js'
server_acc_tests:
expand: true,
flatten: false,
cwd: 'test/unit/coffee',
@ -35,8 +43,10 @@ module.exports = (grunt) ->
nodemon:
dev:
script: 'app.js'
options:
file: 'app.js'
ext:"*.coffee"
concurrent:
dev:
@ -50,7 +60,12 @@ module.exports = (grunt) ->
options:
reporter: grunt.option('reporter') or 'spec'
grep: grunt.option("grep")
acceptence:
src: ["test/acceptence/js/#{grunt.option('feature') or '**'}/*.js"]
options:
reporter: grunt.option('reporter') or 'spec'
grep: grunt.option("grep")
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-watch'
@ -60,6 +75,8 @@ module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-mocha-test'
grunt.registerTask "test:unit", ["coffee", "mochaTest:unit"]
grunt.registerTask "test:acceptence", ["coffee", "mochaTest:acceptence"]
grunt.registerTask "ci", "test:unit"
grunt.registerTask 'default', ['coffee', 'concurrent']

View file

@ -34,4 +34,5 @@ module.exports =
if !key?
key = uuid.v1()
key = key.replace(/\//g,"-")
console.log Settings.path.uploadFolder, key
path.join(Settings.path.uploadFolder, key)

View file

@ -13,14 +13,6 @@ _ = require("underscore")
thirtySeconds = 30 * 1000
printSockets = ->
console.log require('https').globalAgent.sockets
console.log require('http').globalAgent.sockets
setTimeout printSockets, thirtySeconds
printSockets()
buildDefaultOptions = (bucketName, method, key)->
return {
aws:
@ -56,7 +48,6 @@ module.exports =
logger.err err:err, bucketName:bucketName, key:key, fsPath:fsPath, "error emmited on put of file"
callback err
sendStream: (bucketName, key, readStream, callback)->
logger.log bucketName:bucketName, key:key, "sending file to s3"
readStream.on "error", (err)->

View file

@ -27,7 +27,7 @@
"grunt-contrib-requirejs": "0.4.1",
"grunt-contrib-coffee": "0.7.0",
"grunt-contrib-watch": "0.5.3",
"grunt-nodemon": "0.1.2",
"grunt-nodemon": "0.2.1",
"grunt-contrib-clean": "0.5.0",
"grunt-concurrent": "0.4.2"
}

View file

@ -0,0 +1,55 @@
assert = require("chai").assert
sinon = require('sinon')
chai = require('chai')
should = chai.should()
expect = chai.expect
modulePath = "../../../app/js/LocalFileWriter.js"
SandboxedModule = require('sandboxed-module')
fs = require("fs")
request = require("request")
settings = require("settings-sharelatex")
describe "Sending a file", ->
before (done)->
@localFileReadPath = "/tmp/filestore_acceptence_tests_file_read.txt"
@localFileWritePath = "/tmp/filestore_acceptence_tests_file_write.txt"
@constantFileContent = [
"hello world"
"line 2 goes here #{Math.random()}"
"there are 3 lines in all"
].join("\n")
fs.writeFile(@localFileReadPath, @constantFileContent, done)
@filestoreUrl = "http://localhost:#{settings.internal.filestore.port}"
beforeEach (done)->
fs.unlink @localFileWritePath, ->
done()
it "should send a 200 for status endpoing", (done)->
request "#{@filestoreUrl}/status", (err, response, body)->
response.statusCode.should.equal 200
body.indexOf("filestore").should.not.equal -1
body.indexOf("up").should.not.equal -1
done()
it "should be able get the file back", (done)->
@timeout(1000 * 10)
@fileUrl = "#{@filestoreUrl}/project/acceptence_tests/file/12345"
writeStream = request.post(@fileUrl)
writeStream.on "end", =>
request.get @fileUrl, (err, response, body)=>
body.should.equal @constantFileContent
done()
fs.createReadStream(@localFileReadPath).pipe writeStream