Add tests for (non)existent text indices

This commit is contained in:
Ante Pušić 2024-02-18 18:41:53 +01:00
parent d7fc3bb65a
commit 5724708db7

View File

@ -11,6 +11,7 @@
import sys
import gqlalchemy
import mgclient
import pytest
from common import memgraph, memgraph_with_mixed_data, memgraph_with_text_indexed_data
@ -36,6 +37,22 @@ def test_drop_index(memgraph):
assert list(index_info) == []
def test_create_existing_index(memgraph):
memgraph.execute("""CREATE TEXT INDEX duplicatedIndex ON :Document;""")
with pytest.raises(
gqlalchemy.exceptions.GQLAlchemyDatabaseError, match='Text index "duplicatedIndex" already exists.'
) as _:
memgraph.execute("""CREATE TEXT INDEX duplicatedIndex ON :Document;""")
memgraph.execute("""DROP TEXT INDEX duplicatedIndex;""") # cleanup
def test_drop_nonexistent_index(memgraph):
with pytest.raises(
gqlalchemy.exceptions.GQLAlchemyDatabaseError, match='Text index "noSuchIndex" doesnt exist.'
) as _:
memgraph.execute("""DROP TEXT INDEX noSuchIndex;""")
def test_text_search_given_property(memgraph_with_text_indexed_data):
result = list(memgraph_with_text_indexed_data.execute_and_fetch(GET_RULES_2024_DOCUMENT))