Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexrios/ztests
Easy integrations tests with containers
https://github.com/alexrios/ztests
containers docker docker-container feedback go golang hacktoberfest pool postgres pq sqlx test-automation test-containers testing testing-tools
Last synced: 4 months ago
JSON representation
Easy integrations tests with containers
- Host: GitHub
- URL: https://github.com/alexrios/ztests
- Owner: alexrios
- Created: 2019-08-10T21:54:11.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-07T17:50:05.000Z (about 4 years ago)
- Last Synced: 2024-09-27T02:04:16.148Z (4 months ago)
- Topics: containers, docker, docker-container, feedback, go, golang, hacktoberfest, pool, postgres, pq, sqlx, test-automation, test-containers, testing, testing-tools
- Language: Go
- Homepage:
- Size: 58.6 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Z Tests
Golang tests with containers without friction[![Go Report Card](https://goreportcard.com/badge/github.com/alexrios/ztests)](https://goreportcard.com/report/github.com/alexrios/ztests)
## 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](https://github.com/testcontainers/testcontainers-go) and
[Canned Containers](https://github.com/alexrios/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```go
import (
"context"
"github.com/alexrios/ztests/postgres"
"testing"
)func Test(t *testing.T) {
ctx := context.Background()
testEnv, err := postgres.Setup()
defer testEnv.Teardown()
conn, err := testEnv.DB.Conn(ctx)
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](https://twitter.com/alextrending)!