blob: 5779f85c0418840ca659a59e4737a881cf5b0b00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package postgres
import (
"github.com/testcontainers/testcontainers-go"
)
type options struct {
// SQLDriverName is the name of the SQL driver to use.
SQLDriverName string
Snapshot string
}
func defaultOptions() options {
return options{
SQLDriverName: "postgres",
Snapshot: defaultSnapshotName,
}
}
// Compiler check to ensure that Option implements the testcontainers.ContainerCustomizer interface.
var _ testcontainers.ContainerCustomizer = (Option)(nil)
// Option is an option for the Redpanda container.
type Option func(*options)
// Customize is a NOOP. It's defined to satisfy the testcontainers.ContainerCustomizer interface.
func (o Option) Customize(*testcontainers.GenericContainerRequest) error {
// NOOP to satisfy interface.
return nil
}
// WithSQLDriver sets the SQL driver to use for the container.
// It is passed to sql.Open() to connect to the database when making or restoring snapshots.
// This can be set if your app imports a different postgres driver, f.ex. "pgx"
func WithSQLDriver(driver string) Option {
return func(o *options) {
o.SQLDriverName = driver
}
}
|