modulepackage
1.0.2
Repository: https://github.com/teran/go-docker-testsuite.git
Documentation: pkg.go.dev
# README
go-docker-testsuite
Library to run any third-party dependency in Docker on any platform Docker supports The main purpose is to allow runnings integration tests against almost any database or other dependency running right within docker and available via network.
Applications
The test suite provides some of applications, i.e. wrappers for particular docker image, here's the list:
- MinIO
- MySQL/MariaDB/Percona Server
- PostgreSQL
- Redis
- ScyllaDB
Each application could provide its own interface to interact so please refer to applications package for some examples.
Example usage
Go Docker Testsuite provides its own interface for each application aiming to make it clean and easy to use each particular application.
Here's an example for MySQL database:
package main
import (
"context"
"database/sql"
_ "github.com/go-sql-driver/mysql"
"github.com/teran/go-docker-testsuite/applications/mysql"
)
func main() {
ctx := context.Background()
app, err := mysql.New(ctx, "index.docker.io/library/mysql:8.0.4")
if err != nil {
panic(err)
}
defer app.Close(ctx)
if err := app.CreateDB(ctx, "important_database"); err != nil {
panic(err)
}
db, err := sql.Open("mysql", app.MustDSN("important_database"))
if err != nil {
panic(err)
}
if err := db.Ping(); err != nil {
panic(err)
}
if _, err := db.ExecContext(ctx, "SELECT 1"); err != nil {
panic(err)
}
}
# Functions
DockerIP returns docker node IP address for further connectivity usage.
No description provided by the author
New creates new container instance from remote docker image.
NewContainerWithClient creates new container from remote docker image and allows to pass custom docker.Client instance.
NewEnvironment creates new Environment instance.
NewExactMatcher represents exact matcher i.e.
No description provided by the author
No description provided by the author
NewHostConfig creates new HostConfig instance.
NewPortBindings creates new PortBindings instance.
NewPortBindingsWithTCPPortAllocator creates new PortBinding instance and allows to pass custom port allocation function.
No description provided by the author
NewSubstringMatcher represents partial matcher.
RandomPortTCP makes a query to the kernel about free high range IP address NOTE: it have some probability impact so could fail in the really small amount of cases.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ProtoTCP ...
ProtoUDP ...
# Structs
No description provided by the author
Binding reflects a mapping part of the internal & external port of the container.
HostConfigSpec is just a wrapper structure to pass host configuration to the container.
HostPort allows to return host & port from the URL method.
PortBindings is a full mapping of internal & external docker container ports.
# Type aliases
No description provided by the author
Environment represents the container environment passed into runtime.
No description provided by the author
No description provided by the author
Matcher allows to create any kind of matcher for container outputs.
No description provided by the author
Protocol to be NAT'ed from the container.