1.0.2 • Published 7 years ago

rabbit-test-helper v1.0.2

Weekly downloads
48
License
ISC
Repository
github
Last release
7 years ago

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 })
})
1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago