Skip to content

Commit aef58f4

Browse files
authored
INTPYTHON-447 Fix integration test handling (#28)
1 parent 696c012 commit aef58f4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.github/workflows/_test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ jobs:
5151
MONGODB_URI: ${{ secrets.MONGODB_ATLAS_URI }}
5252
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
5353
run: |
54-
[[ "${{ github.repository_owner }}" == "langchain-ai" ]] && make integration_tests || true
54+
if [[ "${{ github.event_name }}" == "push" ]]; then
55+
make integration_tests
56+
fi
5557
working-directory: ${{ inputs.working-directory }}
5658

5759
- name: Ensure the tests did not create any additional files

libs/mongodb/tests/integration_tests/test_index.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ def collection() -> Generator:
2222
"""Depending on uri, this could point to any type of cluster."""
2323
uri = os.environ.get("MONGODB_URI")
2424
client: MongoClient = MongoClient(uri)
25-
client[DB_NAME].create_collection(COLLECTION_NAME)
25+
if COLLECTION_NAME not in client[DB_NAME].list_collection_names():
26+
clxn = client[DB_NAME].create_collection(COLLECTION_NAME)
27+
else:
28+
clxn = client[DB_NAME][COLLECTION_NAME]
2629
clxn = client[DB_NAME][COLLECTION_NAME]
30+
clxn.delete_many({})
2731
yield clxn
28-
clxn.drop()
32+
clxn.delete_many({})
2933

3034

3135
def test_search_index_drop_add_delete_commands(collection: Collection) -> None:

0 commit comments

Comments
 (0)