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
- Host: GitHub
- URL: https://github.com/nhatthm/testcontainers-go-registry
- Owner: nhatthm
- License: mit
- Created: 2022-01-31T16:20:41.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-01T08:35:43.000Z (about 2 years ago)
- Last Synced: 2024-05-01T21:04:59.655Z (about 2 years ago)
- Topics: container, docker, go, golang, image-registry, test, test-integration, testcontainers, testcontainers-go, testcontainers-go-contrib
- Language: Go
- Homepage:
- Size: 848 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Testcontainers-Go Common Image Registry
[](https://github.com/nhatthm/testcontainers-go-registry/releases/latest)
[](https://github.com/nhatthm/testcontainers-go-registry/actions/workflows/test.yaml)
[](https://codecov.io/gh/nhatthm/testcontainers-go-registry)
[](https://goreportcard.com/report/go.nhat.io/testcontainers-registry)
[](https://pkg.go.dev/go.nhat.io/testcontainers-registry)
[](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
[](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY)
or scan this