Skip to content

Commit

Permalink
tests: Perform env-var checking skips sooner as to speed up tests (tm…
Browse files Browse the repository at this point in the history
  • Loading branch information
tmc authored Mar 21, 2024
1 parent 3da52d3 commit 60fa95d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
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

0 comments on commit 60fa95d

Please sign in to comment.