Skip to content

Commit 1d901d9

Browse files
mdelapenyaclaude
andauthored
chore(qdrant): use Run function (#3427)
* chore(qdrant): use Run function This commit updates the qdrant module to use the new Run() API from testcontainers-go, replacing the deprecated GenericContainer approach. The migration converts exposed ports and wait strategy to moduleOpts, simplifying the container creation process. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * chore: simplify wait.ForAll --------- Co-authored-by: Claude <[email protected]>
1 parent eba852e commit 1d901d9

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

modules/qdrant/qdrant.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,24 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize
2222

2323
// Run creates an instance of the Qdrant container type
2424
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*QdrantContainer, error) {
25-
req := testcontainers.ContainerRequest{
26-
Image: img,
27-
ExposedPorts: []string{"6333/tcp", "6334/tcp"},
28-
WaitingFor: wait.ForAll(
25+
moduleOpts := []testcontainers.ContainerCustomizer{
26+
testcontainers.WithExposedPorts("6333/tcp", "6334/tcp"),
27+
testcontainers.WithWaitStrategy(
2928
wait.ForListeningPort("6333/tcp").WithStartupTimeout(5*time.Second),
3029
wait.ForListeningPort("6334/tcp").WithStartupTimeout(5*time.Second),
3130
),
3231
}
3332

34-
genericContainerReq := testcontainers.GenericContainerRequest{
35-
ContainerRequest: req,
36-
Started: true,
37-
}
38-
39-
for _, opt := range opts {
40-
if err := opt.Customize(&genericContainerReq); err != nil {
41-
return nil, err
42-
}
43-
}
33+
moduleOpts = append(moduleOpts, opts...)
4434

45-
container, err := testcontainers.GenericContainer(ctx, genericContainerReq)
35+
ctr, err := testcontainers.Run(ctx, img, moduleOpts...)
4636
var c *QdrantContainer
47-
if container != nil {
48-
c = &QdrantContainer{Container: container}
37+
if ctr != nil {
38+
c = &QdrantContainer{Container: ctr}
4939
}
5040

5141
if err != nil {
52-
return c, fmt.Errorf("generic container: %w", err)
42+
return c, fmt.Errorf("run qdrant: %w", err)
5343
}
5444

5545
return c, nil

0 commit comments

Comments
 (0)