Skip to content

Commit

Permalink
fixing up a transport test
Browse files Browse the repository at this point in the history
  • Loading branch information
esatterwhite committed May 28, 2017
1 parent 4754c0a commit 7770d57
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
27 changes: 20 additions & 7 deletions test/integration/custom-transport.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ test('server', (t) => {
, transports: [foobar]
})
.load()
.listen(5555, null, null, ttt.end)
.listen(5555, null, null, (err) => {
ttt.error(err)
ttt.end()
})
})

tt.test('tap transport', (ttt) => {
Expand Down Expand Up @@ -76,28 +79,38 @@ test('server', (t) => {
, app: 'spec'
}
, seeds: [`${hostname}:6543`]
, transports: [path.resolve(__dirname, 'tap.transport')]
, storage: {
backend: 'leveldown'
, path: '/tmp/sk22'
}
, transports: [require.resolve(path.join(__dirname, 'test.transport'))]
})
.load()
.listen(5555, null, null, ttt.end)
.listen(5555, null, null, (err) => {
console.log('ending')
ttt.error(err)
ttt.end()
})
})

tt.test('tap transport', (ttt) => {
console.log('requesting')
supertest('http://localhost:5555')
.post('/timer')
.send({
timeout: 250
, data: { put: ttt.ok, foobar: 1}
, data: 'hello world'
, callback: {
transport: 'tap'
transport: 'http'
, method: 'put'
, uri: 'doesn\'t matter'
, uri: 'http://localhost:4444'
}
})
.expect(201)
.end((err, res) => {
console.log('response')
ttt.error(err)
ttt.type(server._timers.transports.tap, 'function')
ttt.type(server._timers.transports.test, 'function')
ttt.end()
})
})
Expand Down
8 changes: 8 additions & 0 deletions test/integration/test.transport
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use string'

if (require.main === module) return

module.exports = function test(method, url ,payload, id, storage) {
console.log('test transport')
storage.remove(id)
}

0 comments on commit 7770d57

Please sign in to comment.