Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Perform env-var checking skips sooner as to speed up tests #706

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions vectorstores/chroma/chroma_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,11 @@ func TestChromaAsRetrieverWithMetadataFilters(t *testing.T) {
func getValues(t *testing.T) (string, string) {
t.Helper()

openaiAPIKey := os.Getenv(chroma.OpenAIAPIKeyEnvVarName)
if openaiAPIKey == "" {
t.Skipf("Must set %s to run test", chroma.OpenAIAPIKeyEnvVarName)
}

chromaURL := os.Getenv(chroma.ChromaURLKeyEnvVarName)
if chromaURL == "" {
chromaContainer, err := tcchroma.RunContainer(context.Background(), testcontainers.WithImage("chromadb/chroma:0.4.24"))
Expand All @@ -579,11 +584,6 @@ func getValues(t *testing.T) (string, string) {
}
}

openaiAPIKey := os.Getenv(chroma.OpenAIAPIKeyEnvVarName)
if openaiAPIKey == "" {
t.Skipf("Must set %s to run test", chroma.OpenAIAPIKeyEnvVarName)
}

return chromaURL, openaiAPIKey
}

Expand Down
9 changes: 5 additions & 4 deletions vectorstores/milvus/milvus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func getEmbedder(t *testing.T) (embeddings.Embedder, error) {

func getNewStore(t *testing.T, opts ...Option) (Store, error) {
t.Helper()
e, err := getEmbedder(t)
if err != nil {
return Store{}, err
}

url := os.Getenv("MILVUS_URL")
if url == "" {
milvusContainer, err := tcmilvus.RunContainer(context.Background(), testcontainers.WithImage("milvusdb/milvus:v2.3.9"))
Expand All @@ -55,10 +60,6 @@ func getNewStore(t *testing.T, opts ...Option) (Store, error) {
config := client.Config{
Address: url,
}
e, err := getEmbedder(t)
if err != nil {
return Store{}, err
}
idx, err := entity.NewIndexAUTOINDEX(entity.L2)
if err != nil {
return Store{}, err
Expand Down
9 changes: 5 additions & 4 deletions vectorstores/opensearch/opensearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func getEnvVariables(t *testing.T) (string, string, string) {
var osUser string
var osPassword string

openaiKey := os.Getenv("OPENAI_API_KEY")
if openaiKey == "" {
t.Skipf("Must set %s to run test", "OPENAI_API_KEY")
}

opensearchEndpoint := os.Getenv("OPENSEARCH_ENDPOINT")
if opensearchEndpoint == "" {
openseachContainer, err := tcopensearch.RunContainer(context.Background(), testcontainers.WithImage("opensearchproject/opensearch:2.11.1"))
Expand Down Expand Up @@ -62,10 +67,6 @@ func getEnvVariables(t *testing.T) (string, string, string) {
t.Skipf("Must set %s to run test", "OPENSEARCH_PASSWORD")
}
}
openaiKey := os.Getenv("OPENAI_API_KEY")
if openaiKey == "" {
t.Skipf("Must set %s to run test", "OPENAI_API_KEY")
}

return opensearchEndpoint, opensearchUser, opensearchPassword
}
Expand Down
Loading