Skip to content
forked from alexrios/ztests

Easy integrations tests with containers

Notifications You must be signed in to change notification settings

belintani/ztests

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Z Tests

Golang tests with containers without friction

Go Report Card

Getting started

The purpose is to make testing docker containers easier without having to worry about managing them. The main goal of this library is to be as transparent as possible when it comes to a simple suite of unit tests.

To achieve this results this project uses Test Containers Go and Canned Containers

Example

This example has 3 easy steps:

  • Call Setup() to receive a db connection and a termination function
  • defer teardown() to handle all the docker parts
  • The test itself
import (
	"context"
	"github.com/alexrios/ztests/postgres"
	"testing"
)
func Test(t *testing.T) {
	db, teardown := postgres.Setup(t)
	defer teardown()
	conn, err := db.Conn(ctx := context.Background())
	if err != nil {
		t.Fatal(err)
	}
	var twelve int
	row := conn.QueryRowContext(ctx, "select $1", 12)
	err = row.Scan(&twelve)
	if err != nil {
		t.Fatal(err)
	}
	if twelve != 12 {
		t.FailNow()
	}
}

TODO

[x] support for Postgres canned container

[ ] support for Redis canned container

[ ] support for Elastic Search canned container

[ ] support for MySQL Search canned container

[ ] support for nginx Search canned container

[ ] and many more...

Contributing

If you have any questions or feedback regarding ztests, bring it! Your feedback is always welcome.

Getting help?

Hit me on twitter @alextrending!

About

Easy integrations tests with containers

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%