Documentation
¶
Overview ¶
Package firebird provides a Testcontainers module for running Firebird database containers.
Index ¶
- func WithDatabase(name string) testcontainers.CustomizeRequestOption
- func WithPassword(password string) testcontainers.CustomizeRequestOption
- func WithSYSDBAPassword(password string) testcontainers.CustomizeRequestOption
- func WithUsername(user string) testcontainers.CustomizeRequestOption
- type Container
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithDatabase ¶
func WithDatabase(name string) testcontainers.CustomizeRequestOption
WithDatabase sets the FIREBIRD_DATABASE environment variable to configure the name of the database file to create or connect to.
func WithPassword ¶
func WithPassword(password string) testcontainers.CustomizeRequestOption
WithPassword sets the FIREBIRD_PASSWORD environment variable to configure the password for the database user.
func WithSYSDBAPassword ¶
func WithSYSDBAPassword(password string) testcontainers.CustomizeRequestOption
WithSYSDBAPassword sets the ISC_PASSWORD environment variable to configure the SYSDBA master password.
func WithUsername ¶
func WithUsername(user string) testcontainers.CustomizeRequestOption
WithUsername sets the FIREBIRD_USER environment variable to configure the database user.
Types ¶
type Container ¶
type Container struct {
testcontainers.Container
// contains filtered or unexported fields
}
Container represents the Firebird container type used in the module.
func Run ¶
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
Run creates an instance of the Firebird container type. The default image is jacobalberty/firebird:v3.0.
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/firebird"
)
func main() {
// runFirebirdContainer {
ctx := context.Background()
firebirdContainer, err := firebird.Run(ctx,
"jacobalberty/firebird:v3.0",
firebird.WithDatabase("test.fdb"),
firebird.WithUsername("test"),
firebird.WithPassword("test"),
)
defer func() {
if err := testcontainers.TerminateContainer(firebirdContainer); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// }
state, err := firebirdContainer.State(ctx)
if err != nil {
log.Printf("failed to get container state: %s", err)
return
}
fmt.Println(state.Running)
}
Output: true
func (*Container) ConnectionString ¶
ConnectionString returns the connection string for the Firebird container. It uses the firebird:// scheme and the full server-side path to the database file (/firebird/data/<name>), which is where the jacobalberty/firebird image creates the database. IPv6 hosts are handled correctly via net.JoinHostPort.