Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
Merge branch 'initial_commit' of https://github.com/GannettDigital/fudd
Browse files Browse the repository at this point in the history
… into initial_commit

# Conflicts:
#	test/unit/fudd.js
  • Loading branch information
jhaugh42 committed Jun 20, 2016
2 parents 6d77b27 + 3dea2e2 commit ad56560
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 6 deletions.
78 changes: 74 additions & 4 deletions test/integration/fudd.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,89 @@
var expect = require('chai').expect;
var fudd = require('../../index.js');
var config = require('config');
var series = require('palinode').series;

describe('fudd integration test', function() {
this.timeout(5000);

before('setup', function(done) {
var verificationChannel;
var verificationConnection;
var messageCounter = 0;

it('should setup the infrastructure without error', function(done) {
fudd.setup(config, done);
});

it('should do stuff', function(done) {
setTimeout(done, 4000);
config.exchanges.forEach(function(exchangeDefinition) {
it('should verify the exchange ' + exchangeDefinition.name + ' exists', function(done) {
var establishChannel = [fudd._connect.bind(null, config), fudd._createChannel];
series(establishChannel, function(err, connection, channel) {
if (err) return done(err);

channel.checkExchange(exchangeDefinition.name, function(err) {
if (err) return done(err);

fudd._disconnect(connection, done);
});

});
});
});

config.queues.forEach(function(queueDefinition) {
it('should verify the queue ' + queueDefinition.name + ' exists', function(done) {
var establishChannel = [fudd._connect.bind(null, config), fudd._createChannel];
series(establishChannel, function(err, connection, channel) {
if (err) return done(err);

channel.checkQueue(queueDefinition.name, function(err) {
if (err) return done(err);

fudd._disconnect(connection, done);
});
});
});
});

it('should establish channel for messages', function(done) {
var establishChannel = [fudd._connect.bind(null, config), fudd._createChannel];
series(establishChannel, function(err, connection, channel) {
if (err) return done(err);

verificationChannel = channel;
verificationConnection = connection;

done();
});
});

// specific tests
it('should publish messages to the fanout', function() {
verificationChannel.publish('fanout.fx', 'some.key', new Buffer('message1'));
verificationChannel.publish('fanout.fx', 'key.topic1', new Buffer('message1'));
verificationChannel.publish('fanout.fx', 'key.topic2', new Buffer('message1'));
});

config.queues.forEach(function(queueDefinition) {
it('should purge the ' + queueDefinition.name + ' queue', function(done) {
verificationChannel.purgeQueue(queueDefinition.name, function(err, ok) {
messageCounter += ok.messageCount;
done();
});
});
});

it('should have come across corret number of messages', function() {
// msg - route
// 1 - fanout to queue1
// 2 - fanout to queue1
// 3 - fanout to queue1
// 2 - fanout to topic to queue2
// 3 - fanout to topic to queue2
expect(messageCounter).to.equal(5);
});

after('teardown', function(done) {
it('should teardown the infrastructure without error', function(done) {
fudd.teardown(config, done);
});
});
3 changes: 1 addition & 2 deletions test/unit/fudd.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('fudd', function() {
mockery.registerMock('./amqp-config-utils.js', {});
Fudd = require('../../lib/fudd.js');
});

before('setup stubs', function() {
callbackSpy = sinon.spy();
connectBindStub = sinon.stub(Fudd._connect, 'bind').returns(boundConnect);
Expand Down Expand Up @@ -179,7 +179,6 @@ describe('fudd', function() {
deleteQueueBindStub.reset();
Fudd.teardown(config, callbackSpy);
});

});
});
});

0 comments on commit ad56560

Please sign in to comment.