From 5f2af9050a802e092e843689f9c947d60ae67957 Mon Sep 17 00:00:00 2001 From: Gabor Volfinger Date: Wed, 29 Jun 2022 16:31:51 +0200 Subject: [PATCH] add e2e test prototype --- tests/e2e/CMakeLists.txt | 1 + tests/e2e/util_e2e/CMakeLists.txt | 5 +++++ tests/e2e/util_e2e/simple_case_nullcheck.py | 23 +++++++++++++++++++++ tests/e2e/util_e2e/workloads.yaml | 13 ++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 tests/e2e/util_e2e/CMakeLists.txt create mode 100644 tests/e2e/util_e2e/simple_case_nullcheck.py create mode 100644 tests/e2e/util_e2e/workloads.yaml diff --git a/tests/e2e/CMakeLists.txt b/tests/e2e/CMakeLists.txt index 1bb23f176..1aaa15275 100644 --- a/tests/e2e/CMakeLists.txt +++ b/tests/e2e/CMakeLists.txt @@ -40,6 +40,7 @@ add_subdirectory(write_procedures) add_subdirectory(magic_functions) add_subdirectory(module_file_manager) add_subdirectory(monitoring_server) +add_subdirectory(util_e2e) copy_e2e_python_files(pytest_runner pytest_runner.sh "") file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/memgraph-selfsigned.crt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/tests/e2e/util_e2e/CMakeLists.txt b/tests/e2e/util_e2e/CMakeLists.txt new file mode 100644 index 000000000..8b9b2a4fa --- /dev/null +++ b/tests/e2e/util_e2e/CMakeLists.txt @@ -0,0 +1,5 @@ +function(copy_util_e2e_python_files FILE_NAME) + copy_e2e_python_files(write_procedures ${FILE_NAME}) +endfunction() + +copy_util_e2e_python_files(simple_case_nullcheck.py) diff --git a/tests/e2e/util_e2e/simple_case_nullcheck.py b/tests/e2e/util_e2e/simple_case_nullcheck.py new file mode 100644 index 000000000..54e2aa42c --- /dev/null +++ b/tests/e2e/util_e2e/simple_case_nullcheck.py @@ -0,0 +1,23 @@ +import typing +import mgclient +import sys +import pytest + + +def test_nullcheck_yields_error(connection): + cursor = connection.cursor() + query = """WITH 2 AS name + RETURN CASE name + WHEN 3 THEN 'works' + WHEN null THEN "doesn't work" + ELSE 'something went wrong' + END""" + + cursor.execute(query) + row = cursor.fetchone() + + assert row == "Use the generic form when checking against NULL." + + +if __name__ == "__main__": + sys.exit(pytest.main([__file__, "-rA"])) diff --git a/tests/e2e/util_e2e/workloads.yaml b/tests/e2e/util_e2e/workloads.yaml new file mode 100644 index 000000000..fa92329b5 --- /dev/null +++ b/tests/e2e/util_e2e/workloads.yaml @@ -0,0 +1,13 @@ +template_cluster: &template_cluster + cluster: + main: + args: ["--bolt-port", "7687", "--log-level=TRACE"] + log_file: "util-e2e.log" + setup_queries: [] + validation_queries: [] + +workloads: + - name: "CASE throws if simple form is used and checking against NULL" + binary: "tests/e2e/pytest_runner.sh" + args: ["util_e2e/simple_case_nullcheck.py"] + <<: *template_cluster