Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCollection ¶
func WithCollection(name string) testcontainers.CustomizeRequestOption
WithCollection returns a testcontainers.CustomizeRequestOption that creates a named Solr collection after the container is ready. It returns an error if the collection creation command exits with a non-zero status, so callers can be sure the collection exists once Run returns without error.
Types ¶
type Container ¶
type Container struct {
testcontainers.Container
}
Container represents the Solr 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 Solr container type.
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/solr"
)
func main() {
// runSolrContainer {
ctx := context.Background()
solrContainer, err := solr.Run(ctx, "solr:9",
solr.WithCollection("myCollection"),
)
defer func() {
if err := testcontainers.TerminateContainer(solrContainer); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// }
state, err := solrContainer.State(ctx)
if err != nil {
log.Printf("failed to get container state: %s", err)
return
}
fmt.Println(state.Running)
}
Output: true
Click to show internal directories.
Click to hide internal directories.