Skip to content

Commit

Permalink
More test for hub pubsub.
Browse files Browse the repository at this point in the history
  • Loading branch information
lsm committed Apr 5, 2016
1 parent 801de1f commit 5f8ef3e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions test/hub.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ module.exports = function() {
var tlsEndpoint = 'tls://localhost:46364'

// Servers
smqHub.bind(eioEndpoint)
smqHub.bind(tcpEndpoint, function(stream) {
t.ok(stream)
smqHub.bind(eioEndpoint, function(stream) {
t.ok(stream, 'eio stream')
})
smqHub.bind(tcpEndpoint)
smqHub.bind(tlsEndpoint, {
key: fs.readFileSync(certPath + '/server-key.pem'),
cert: fs.readFileSync(certPath + '/server-cert.pem'),
Expand All @@ -40,20 +40,26 @@ module.exports = function() {
eioClient = socketmq.connect(eioEndpoint)
tcpClient = socketmq.connect(tcpEndpoint)
tlsClient = socketmq.connect(tlsEndpoint, tlsClientOptions)

eioClient.pub('eio pub', ['eio', 3])
})

test('hub: pub/sub', function(t) {
t.plan(2)
t.plan(4)
var msg = 'hub pub sub'

eioClient.sub('pub sub', function(arg1) {
t.equal(arg1, msg)
t.equal(arg1, msg, 'eio get pub from tls')
})
tcpClient.sub('pub sub', function(arg1) {
t.equal(arg1, msg)
t.equal(arg1, msg, 'tcp get pub from tls')
})
tlsClient.sub('pub sub', function() {
t.notOk(true)
t.notOk(true, 'tls should not get pub msg from itself')
})
tlsClient.sub('eio pub', function(arr) {
t.equal(arr[0], 'eio', 'eio->tls arr[0] match')
t.equal(arr[1], 3, 'eio->tls arr[1] match')
})

tlsClient.pub('pub sub', msg)
Expand Down

0 comments on commit 5f8ef3e

Please sign in to comment.