testcontainerscommon

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: MIT Imports: 0 Imported by: 0

README

Testcontainers-Go Common Image Registry

GitHub Releases Build Status codecov Go Report Card GoDevDoc Donate

Common Image Registry for Testcontainers-Go

Prerequisites

  • Go >= 1.16

Install

go get github.com/nhatthm/testcontainers-go-common

MySQL

package example

import (
	"context"

	testcontainersmysql "github.com/nhatthm/testcontainers-go-common/sql/mysql"
	testcontainers "github.com/nhatthm/testcontainers-go-extra"
)

const (
	dbName          = "test"
	dbUser          = "test"
	dbPassword      = "test"
	migrationSource = "file://./resources/migrations/"
)

func startMySQL() (testcontainers.Container, error) {
	return testcontainersmysql.StartGenericContainer(context.Background(),
		dbName, dbUser, dbPassword,
		testcontainersmysql.RunMigrations(migrationSource),
	)
}

Postgres

package example

import (
	"context"

	testcontainerspostgres "github.com/nhatthm/testcontainers-go-common/sql/postgres"
	testcontainers "github.com/nhatthm/testcontainers-go-extra"
)

const (
	dbName          = "test"
	dbUser          = "test"
	dbPassword      = "test"
	migrationSource = "file://./resources/migrations/"
)

func startMySQL() (testcontainers.Container, error) {
	return testcontainerspostgres.StartGenericContainer(context.Background(),
		dbName, dbUser, dbPassword,
		testcontainerspostgres.RunMigrations(migrationSource),
	)
}

Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

Paypal donation

paypal

       or scan this

Documentation

Overview

Package testcontainerscommon provides common container requests.

Directories

Path Synopsis
sql
Package testcontainersql provides common functions for sql images.
Package testcontainersql provides common functions for sql images.
mysql
Package testcontainersmysql provides setup for spinning up a mysql container.
Package testcontainersmysql provides setup for spinning up a mysql container.
postgres
Package testcontainerspostgres provides setup for spinning up a postgres container.
Package testcontainerspostgres provides setup for spinning up a postgres container.

Jump to

Keyboard shortcuts

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