• This repository has been archived on 29/Mar/2022
  • Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language
    Go
  • License
    BSD 2-Clause "Sim...
  • Created over 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Golang AMQP mocking library

Wabbit - Go AMQP Mocking Library

GoDoc Go Report Card

Elmer Fudd: Shhh. Be vewy vewy quiet, I'm hunting wabbits

AMQP is a verbose protocol that makes it difficult to implement proper unit-testing on your application. The first goal of this package is provide a sane interface for an AMQP client implementation based on the specification AMQP-0-9-1 (no extension) and then an implementation of this interface using the well established package streadway/amqp (a wrapper).

What are the advantages of this?

Usage

How to use ?

Testing

This package have an AMQP interface and two possible implementations:

In the same way you can use the http package in your software and use the httptest for testing, when using wabbit is recommended to use the wabbit/amqp package on your software and wabbit/amqptest in your tests. Simple test example:

package main

import (
	"testing"
	"github.com/NeowayLabs/wabbit/amqptest"
	"github.com/NeowayLabs/wabbit/amqptest/server"
	"github.com/NeowayLabs/wabbit/amqp"
)


func TestChannelCreation(t *testing.T) {
	mockConn, err := amqptest.Dial("amqp://localhost:5672/%2f") // will fail,

	if err == nil {
		t.Error("This shall fail, because no fake amqp server is running...")
	}

	fakeServer := server.NewServer("amqp://localhost:5672/%2f")
	fakeServer.Start()

	mockConn, err = amqptest.Dial("amqp://localhost:5672/%2f") // now it works =D

	if err != nil {
		t.Error(err)
	}

	//Now you can use mockConn as a real amqp connection.
	channel, err := mockConn.Channel()

    // ...
}

The package amqptest/server implements a mock AMQP server and it can be used to simulate network partitions or broker crashs. To create a new server instance use server.NewServer passing any amqpuri. You can create more than one server, but they need to have different amqpuris. Example below:

    broker1 := server.NewServer("amqp://localhost:5672/%2f")
    broker2 := server.NewServer("amqp://192.168.10.165:5672/%2f")
    broker3 := server.NewServer("amqp://192.168.10.169:5672/%2f")

    broker1.Start()
    broker2.Start()
    broker3.Start()

Calling NewServer with same amqpuri will return the same server instance.

Use broker.Stop() to abruptly stop the amqp server.

There's no fake clustering support yet (maybe never)

It's a very straightforward implementation that need a lot of improvements yet. Take careful when using it.

[]'s

More Repositories

1

drm

Direct Rendering Manager in pure Go
Go
51
star
2

data-science-template

A template for Data Science projects with a solid Software Engineering Architecture
Makefile
44
star
3

neosearch

Full Text Search Library
Go
30
star
4

cloud-machine

This is a Go Project that should be used to create a cloud environment. The app will create EBS volumes and EC2 instance through AWS, although in the next future it'll be possible use other backends like Microsoft Azure, Google Cloud Platform, etc.
Go
22
star
5

klb

Nash library to automate cloud infrastructure management
Shell
20
star
6

bplustree

Concurrent in-memory B+ Tree featuring optimistic lock coupling
Rust
19
star
7

jobs

A list of jobs available at Neoway
Cypher
16
star
8

gootstrap

Go bootstrap, Gootstrap
Go
15
star
9

goss-cis-benchmark

Goss CIS Benchmark tests
Shell
13
star
10

neowaylabs.github.io

Neoway Labs Tech Blog
SCSS
12
star
11

presentations

Go
12
star
12

es-reindex

Go tool to reindex ElasticSearch indices. You can reindex in different hosts and/or changing the mapping
Go
11
star
13

nashcomplete

Autocomplete for nash shell (in nash script)
Shell
11
star
14

logger

Go logger
Go
10
star
15

jsondiff

Go
10
star
16

postgres-azure-backup

Image prepared to backup PostgreSQL database to Microsoft Azure.
Shell
8
star
17

clinit-cfn-tool

Cloudinit inject/extract into/from AWS CloudFormation
Go
8
star
18

data-integration-challenge

Wanna join Data Integration team? Try solving this challenge and contact us! :)
Makefile
7
star
19

abad

here goes nothing
Go
7
star
20

dojo

Code repository and materials used in Neoway's dojo.
JavaScript
7
star
21

gcloud-pubsub-emulator

This is the Docker image for the Google Cloud PubSub Emulator
Dockerfile
6
star
22

waveparser

Parses data from audio files
Go
5
star
23

es-export

Go tool to export ElasticSearch indices to CSV
Go
5
star
24

dchan-book

Distributed CSP channel - http://neowaylabs.github.io/dchan-book/
C
5
star
25

docker-geoserver

Geoserver docker
Shell
5
star
26

docker-mongodb-mms-agent

This Docker image with MongoDB Monitoring Agent
Shell
5
star
27

docker-glusterfs

Dockerized GlusterFS for usage with Etcd and SkyDNS
Shell
4
star
28

kubernetes-coreos-vagrant

Kubernetes on CoreOS with Vagrant
4
star
29

statsdig

Library and tools to help StatsD Sysdig Integration on Golang code
Go
4
star
30

semantic-release

This project aims to automatically upgrade the release version based on git tags and commit messages.
Go
3
star
31

gofs

Multiple implementations of a generic filesystem interface for Go
Go
3
star
32

testd

Library that makes easier to write tests that depends on runnings daemons/services
Go
3
star
33

terraform-modules

This project has common terraform modules. You can use this modules to build your infrastructure at Cloud follow the Neoway Rules.
HCL
3
star
34

signal

DSP routines
Go
3
star
35

gis

Geographic Information System
Go
3
star
36

packer-images

Repository to automate the distribution of Neoway server base images.
HCL
3
star
37

ansible-wazuh-agent

This role is used for installing and configuring the Wazuh client on Ubuntu and RedHat based operating systems.
Jinja
3
star
38

front-proxy-envoy

This repository is a study of the Envoy, to get an idea of what he has to offer as a frontal proxy.
Go
3
star
39

mysql-azure-backup

Image prepared to backup MySQL database to Microsoft Azure
Shell
3
star
40

fifa-wct-go-example

The responsibility of this project is to store the teams, games and results of the FIFA World Cup.
Go
3
star
41

datahub

Just a POC :-)
Go
3
star
42

ansible-role-ubuntu-hardening

Ubuntu Hardening follow CIS Benchmarks
Makefile
3
star
43

grafana-templates

Collection of Grafana templates
2
star
44

waveform

Generates waveform from audio files
Go
2
star
45

deploy-portus

A cloud-config YAML file for deploying Portus and Registry
2
star
46

docker-emacs-texlive

TeX Live and Emacs in a Docker container.
Shell
2
star
47

pybootstrap

Project with bootstrap files to create one python project
Shell
2
star
48

lodge

A structured logging package in Python simple to use.
Python
2
star
49

docker-ogre

Image used to build & deploy in GitLab C.I.
Dockerfile
1
star
50

pyvaultone

Project to abstract vault one interaction.
Python
1
star
51

scrapy-workshop

Workshop to work with Scrapy
Python
1
star
52

endurance

Automation project to test performance on more than two Datacenter regions
Shell
1
star
53

docs-api

Neoway for Developers
JavaScript
1
star
54

nash-app-example

Shell
1
star
55

list-azure-resources

This project return a csv with Azure Resources in your Subscriptions
Shell
1
star
56

sysdig-client

Project designed to provide a sysdig API easy access interface for capturing metrics
Go
1
star
57

docker-awscli

AWS CLI Containered docker
Dockerfile
1
star
58

jmx_exporter

A process for exposing JMX Beans via HTTP for Prometheus consumption
Makefile
1
star
59

klbdeps

Builds docker image with dependencies for the klb project
Makefile
1
star
60

neosearch-import

Go
1
star
61

mount.cifs_copy

Dockerfile
1
star