mirror of
https://github.com/hanzoai/vector-go.git
synced 2026-10-30 18:18:35 +00:00
The test package would not build:
client.DeleteVectorName undefined (type *"github.com/hanzoai/vector-go/qdrant".Client
has no field or method DeleteVectorName)
undefined: qdrant.DeleteVectorNameRequest
Both exist here — qdrant/points.go:259 and qdrant/points.pb.go:2876. They were
missing because go.mod still declared `module github.com/qdrant/go-client`
while the tests import github.com/hanzoai/vector-go/qdrant, so the module
listed ITSELF as a dependency at v0.1.1 and the tests type-checked against that
published release instead of the tree they sit in. Anything added since v0.1.1
was invisible to its own test suite.
The module is now named where it is published, the self-require is gone, and
the two test files still on the old path follow the other nine.
getClientVersion's packageName came along, and not for tidiness: it compares
that string to bi.Main.Path and to the dependency list to report the client
version, so leaving the old path there would have reported unknownVersion.
go build and go vet are both clean — vet compiles the test package, which is
what could not build before.
98 lines
2.0 KiB
Go
98 lines
2.0 KiB
Go
package qdrant_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/hanzoai/vector-go/qdrant"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestRetryConfig(t *testing.T) {
|
|
apiKey := "<RETRY_TEST>"
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
t.Cleanup(cancel)
|
|
|
|
container, err := standaloneQdrant(ctx, apiKey)
|
|
require.NoError(t, err)
|
|
|
|
err = container.Start(ctx)
|
|
require.NoError(t, err)
|
|
|
|
t.Cleanup(func() {
|
|
err := container.Terminate(ctx)
|
|
require.NoError(t, err)
|
|
})
|
|
|
|
host, err := container.Host(ctx)
|
|
require.NoError(t, err)
|
|
|
|
port, err := container.MappedPort(ctx, "6334/tcp")
|
|
require.NoError(t, err)
|
|
|
|
t.Run("WithRetryConfig", func(t *testing.T) {
|
|
client, err := qdrant.NewClient(&qdrant.Config{
|
|
Host: host,
|
|
Port: int(port.Num()),
|
|
APIKey: apiKey,
|
|
RetryConfig: &qdrant.RetryConfig{
|
|
MaxRetries: 3,
|
|
BaseBackoff: 100 * time.Millisecond,
|
|
MaxBackoff: time.Second,
|
|
},
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
resp, err := client.HealthCheck(ctx)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, resp)
|
|
})
|
|
|
|
t.Run("WithRetryConfigDefaults", func(t *testing.T) {
|
|
client, err := qdrant.NewClient(&qdrant.Config{
|
|
Host: host,
|
|
Port: int(port.Num()),
|
|
APIKey: apiKey,
|
|
RetryConfig: &qdrant.RetryConfig{
|
|
MaxRetries: 3,
|
|
},
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
resp, err := client.HealthCheck(ctx)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, resp)
|
|
})
|
|
|
|
t.Run("WithoutRetryConfig", func(t *testing.T) {
|
|
client, err := qdrant.NewClient(&qdrant.Config{
|
|
Host: host,
|
|
Port: int(port.Num()),
|
|
APIKey: apiKey,
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
resp, err := client.HealthCheck(ctx)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, resp)
|
|
})
|
|
|
|
t.Run("WithZeroMaxRetries", func(t *testing.T) {
|
|
client, err := qdrant.NewClient(&qdrant.Config{
|
|
Host: host,
|
|
Port: int(port.Num()),
|
|
APIKey: apiKey,
|
|
RetryConfig: &qdrant.RetryConfig{
|
|
MaxRetries: 0,
|
|
},
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
resp, err := client.HealthCheck(ctx)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, resp)
|
|
})
|
|
}
|