diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index 7ae4c1d..9b920c8 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -51,7 +51,9 @@ jobs: MONGODB_URI: ${{ secrets.MONGODB_ATLAS_URI }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} run: | - [[ "${{ github.repository_owner }}" == "langchain-ai" ]] && make integration_tests || true + if [[ "${{ github.event_name }}" == "push" ]]; then + make integration_tests + fi working-directory: ${{ inputs.working-directory }} - name: Ensure the tests did not create any additional files diff --git a/libs/mongodb/tests/integration_tests/test_index.py b/libs/mongodb/tests/integration_tests/test_index.py index d8a68d0..b43831b 100644 --- a/libs/mongodb/tests/integration_tests/test_index.py +++ b/libs/mongodb/tests/integration_tests/test_index.py @@ -22,10 +22,14 @@ def collection() -> Generator: """Depending on uri, this could point to any type of cluster.""" uri = os.environ.get("MONGODB_URI") client: MongoClient = MongoClient(uri) - client[DB_NAME].create_collection(COLLECTION_NAME) + if COLLECTION_NAME not in client[DB_NAME].list_collection_names(): + clxn = client[DB_NAME].create_collection(COLLECTION_NAME) + else: + clxn = client[DB_NAME][COLLECTION_NAME] clxn = client[DB_NAME][COLLECTION_NAME] + clxn.delete_many({}) yield clxn - clxn.drop() + clxn.delete_many({}) def test_search_index_drop_add_delete_commands(collection: Collection) -> None: