An open API service indexing awesome lists of open source software.

https://github.com/nhatthm/testcontainers-go-registry

Common Image Registry for Testcontainers-Go
https://github.com/nhatthm/testcontainers-go-registry

container docker go golang image-registry test test-integration testcontainers testcontainers-go testcontainers-go-contrib

Last synced: about 1 year ago
JSON representation

Common Image Registry for Testcontainers-Go

Awesome Lists containing this project

README

          

# Testcontainers-Go Common Image Registry

[![GitHub Releases](https://img.shields.io/github/v/release/nhatthm/testcontainers-go-registry)](https://github.com/nhatthm/testcontainers-go-registry/releases/latest)
[![Build Status](https://github.com/nhatthm/testcontainers-go-registry/actions/workflows/test.yaml/badge.svg)](https://github.com/nhatthm/testcontainers-go-registry/actions/workflows/test.yaml)
[![codecov](https://codecov.io/gh/nhatthm/testcontainers-go-registry/branch/master/graph/badge.svg?token=eTdAgDE2vR)](https://codecov.io/gh/nhatthm/testcontainers-go-registry)
[![Go Report Card](https://goreportcard.com/badge/go.nhat.io/testcontainers-registry)](https://goreportcard.com/report/go.nhat.io/testcontainers-registry)
[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/go.nhat.io/testcontainers-registry)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)

Common Image Registry for Testcontainers-Go

## Prerequisites

- `Go >= 1.22`

## Install

```bash
go get go.nhat.io/testcontainers-registry
```

## Elasticsearch

```go
package example

import (
"context"

es "go.nhat.io/testcontainers-registry/elasticsearch"
testcontainers "go.nhat.io/testcontainers-extra"
)

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

func startElasticsearch() (testcontainers.Container, error) {
return es.StartGenericContainer(context.Background())
}
```

## Mongo

```go
package example

import (
"context"

"go.nhat.io/testcontainers-registry/mongo"
testcontainers "go.nhat.io/testcontainers-extra"
)

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

func startMongoDB() (testcontainers.Container, error) {
return mongo.StartGenericContainer(context.Background(),
mongo.RunMigrations(migrationSource, dbName),
)
}
```

## MySQL

```go
package example

import (
"context"

"go.nhat.io/testcontainers-registry/mysql"
testcontainers "go.nhat.io/testcontainers-extra"
)

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

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

## Postgres

```go
package example

import (
"context"

"go.nhat.io/testcontainers-registry/postgres"
testcontainers "go.nhat.io/testcontainers-extra"
)

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

func startPostgres() (testcontainers.Container, error) {
return postgres.StartGenericContainer(context.Background(),
dbName, dbUser, dbPassword,
postgres.RunMigrations(migrationSource),
)
}
```

## SQL Server

```go
package example

import (
"context"

testcontainers "go.nhat.io/testcontainers-extra"
"go.nhat.io/testcontainers-registry/mssql"
)

const (
dbName = "test"
dbPassword = "My!StrongPassword"
migrationSource = "file://./resources/migrations/"
)

func startSQLServer() (testcontainers.Container, error) {
return mssql.StartGenericContainer(context.Background(),
dbName, dbPassword,
mssql.RunMigrations(migrationSource),
)
}
```

## Options

### Change Image Tag

```go
package example

import (
"context"

"go.nhat.io/testcontainers-registry/postgres"
testcontainers "go.nhat.io/testcontainers-extra"
)

const (
dbName = "test"
dbUser = "test"
dbPassword = "test"
)

func startPostgres() (testcontainers.Container, error) {
return postgres.StartGenericContainer(context.Background(),
dbName, dbUser, dbPassword,
testcontainers.WithImageTag("13-alpine"),
)
}
```

### Change Image Name

```go
package example

import (
"context"

testcontainers "go.nhat.io/testcontainers-extra"
"go.nhat.io/testcontainers-registry/mysql"
)

const (
dbName = "test"
dbUser = "test"
dbPassword = "test"
)

func startMySQL() (testcontainers.Container, error) {
return mysql.StartGenericContainer(context.Background(),
dbName, dbUser, dbPassword,
testcontainers.WithImageName("mariadb"),
testcontainers.WithImageTag("10.7"),
)
}
```

## Donation

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

### Paypal donation

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)

       or scan this