Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithDataDir ¶
func WithDataDir(dir string) testcontainers.CustomizeRequestOption
WithDataDir sets the data directory for the Typesense container.
Types ¶
type Container ¶
type Container struct {
testcontainers.Container
// contains filtered or unexported fields
}
Container represents the Typesense 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 Typesense container type
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/typesense"
)
func main() {
// runTypesenseContainer {
ctx := context.Background()
typesenseContainer, err := typesense.Run(
ctx,
"typesense/typesense:26.0",
typesense.WithAPIKey("my-api-key"),
)
defer func() {
if err := testcontainers.TerminateContainer(typesenseContainer); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// }
state, err := typesenseContainer.State(ctx)
if err != nil {
log.Printf("failed to get container state: %s", err)
return
}
fmt.Println(state.Running)
fmt.Println(typesenseContainer.APIKey())
}
Output: true my-api-key
type Option ¶
type Option func(*options)
Option is a function that configures the Typesense container.
func WithAPIKey ¶
WithAPIKey sets the API key for the Typesense container. The API key is required for all Typesense API calls.
func (Option) Customize ¶
func (o Option) Customize(*testcontainers.GenericContainerRequest) error
Customize is a NOOP. It's defined to satisfy the testcontainers.ContainerCustomizer interface.
Click to show internal directories.
Click to hide internal directories.