Skip to content

A postgres docker testcontainer for go

License

Apache-2.0, Unlicense licenses found

Licenses found

Apache-2.0
LICENSE
Unlicense
UNLICENSE
Notifications You must be signed in to change notification settings

thlib/testcontainerpostgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Postgres testcontainer

A postgres docker testcontainer for go

Example usage:

initPath, err := filepath.Abs("./initdb")
if err != nil {
    log.Fatalf("%v", err)
}
ctx := context.Background()
postgresC, conn, err := testcontainerpostgres.New(ctx, "14.5-alpine",
    testcontainerpostgres.WithInit(initPath),
    testcontainerpostgres.WithDb("test_db"),
    testcontainerpostgres.WithAuth("postgres", "postgres"),
)
if err != nil {
    log.Fatalf("%v", err)
}
defer Terminate(ctx, postgresC)

fmt.Println(conn)
// Output: postgres://postgres:postgres@localhost:49156/test_db

Run tests

go test

About

A postgres docker testcontainer for go

Resources

License

Apache-2.0, Unlicense licenses found

Licenses found

Apache-2.0
LICENSE
Unlicense
UNLICENSE

Stars

Watchers

Forks

Packages

No packages published

Languages