wrapper

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2019 License: MIT Imports: 1 Imported by: 0

README

Build Status

localstack-go-wrapper

A wrapper around LocalStack for integration testing in Go.

Prerequesites
  • Go 1.11 for module support $GO111MODULE=on
  • Docker installed and daemon running
Usage

To start all LocalStack services on the default ports:

package demo

import (
	"log"
	"os"
	"testing"

	"github.com/callumkerredwards/localstack-go-wrapper/localstack"
)

func TestMain(m *testing.M) {
	os.Exit(testMainWrapper(m))
}

func testMainWrapper(m *testing.M) int {
    container, err := localstack.New()
    if err != nil {
        log.Printf("Cannot create localstack, %v", err)
        return 1
    }
    err = container.Start()
    if err != nil {
        log.Printf("Cannot start localstack, %v", err)
        return 1
    }
    defer container.Stop()
	return m.Run()
}

To specify LocalStack services running on a particular port:

package demo

import (
	"log"
	"os"
	"testing"

	"github.com/callumkerredwards/localstack-go-wrapper/localstack"
)

func TestMain(m *testing.M) {
	os.Exit(testMainWrapper(m))
}

func testMainWrapper(m *testing.M) int {
    s3Config := &localstack.ServiceConfig{
        Service: localstack.S3,
        Port: 33000,
    }
    container, err := localstack.New(s3Config)
    if err != nil {
        log.Printf("Cannot create localstack, %v", err)
        return 1
    }
    err = container.Start()
    if err != nil {
        log.Printf("Cannot start localstack, %v", err)
        return 1
    }
    defer container.Stop()
	return m.Run()
}

If the port is not specified, it will use the LocalStack defaults. Remember to ensure that LocalStack is not running elsewhere if using default ports.

Make
  • make can be used to format, lint, install and test this library.

Documentation

Overview

Package wrapper is a wrapper around LocalStack, to make it easier to integration test Go code that use AWS

Directories

Path Synopsis
Package localstack contains the code to start LocalStack in a new docker container
Package localstack contains the code to start LocalStack in a new docker container
services
Package services contains code relating to the AWS services that LocalStack supports
Package services contains code relating to the AWS services that LocalStack supports

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL