rabbit-test-helper
test helper to acceptance tests with rabbit-mq
Last updated 2 months ago by luizzamboni .
ISC · Original npm · Tarball
$ cnpm install rabbit-test-helper 
SYNC missed versions from official npm registry.

RabbitTestHelper

install:

$ npm install rabbit-test-helper --save-dev

use:


const Factory = require("rabbit-test-helper")

const config = {
  url: "amqp://localhost",
  exchange: { 
    name: "app_test",
    routingKeys: [
      { 
        name: "pay_clicks", 
        queues: [
          "clicks_debit",
          "clicks_warehouse"
        ] 
      },
      { 
        name: "clicks", 
        queues: [
          "clicks_warehouse"
        ] 
      }
    ]
  }
}

// generate a helper to build a rabbit objects
let helper = Factory(config)

co(function*() {

  // build a rabbit env structure how described in config
  yield helper.build()

  const message = {
    a: "b"
  }
  // send a message to routeKey
  ok = yield helper.sendTo("pay_clicks", JSON.stringify(message))

  // get a message from querue, but not remove it
  let msg = yield helper.getFrom("clicks_warehouse")

  // get a message from queue, and remove it
  msg = helper.getFrom("clicks_warehouse", { remove: true })
})
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |