meshblu-server-http
Version:
Maybe. Unofficial. You know how it is.
61 lines (49 loc) • 1.78 kB
text/coffeescript
_ = require 'lodash'
request = require 'request'
Server = require '../../src/server'
async = require 'async'
redis = require 'redis'
RedisNS = require '@octoblu/redis-ns'
JobManager = require 'meshblu-core-job-manager'
describe 'GET /publickey', ->
beforeEach (done) ->
= 0xd00d
= new Server
port:
disableLogging: true
jobTimeoutSeconds: 1
namespace: 'meshblu:server:http:test'
jobLogQueue: 'meshblu:job-log'
jobLogRedisUri: 'redis://localhost:6379'
meshbluHost: 'localhost'
meshbluPort: 3000
.run done
afterEach (done) ->
.stop => done()
beforeEach ->
= _.bindAll new RedisNS 'meshblu:server:http:test', redis.createClient()
= new JobManager client: , timeoutSeconds: 1
context 'when the request is successful', ->
beforeEach ->
async.forever (next) =>
.getRequest ['request'], (error, request) =>
next request
return unless request?
response =
metadata:
code: 200
responseId: request.metadata.responseId
data:
publicKey: 'abc123'
.createResponse 'response', response, (error) =>
throw error if error?
beforeEach (done) ->
request.get "http://localhost:#{@port}/publickey", (error, , ) =>
done error
it 'should return a 200', ->
expect(.statusCode).to.equal 200
it 'should have the publicKey in the body', ->
expect(JSON.parse()).to.deep.equal publicKey: 'abc123'
it 'should have the metadata in the headers', ->
expect(.headers).to.containSubset
'x-meshblu-code': '200'