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..5f1877c4f --- /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(util_e2e ${FILE_NAME}) +endfunction() + +copy_util_e2e_python_files(utility_simple.py) diff --git a/tests/e2e/util_e2e/utility_simple.py b/tests/e2e/util_e2e/utility_simple.py new file mode 100644 index 000000000..3bcd32a7a --- /dev/null +++ b/tests/e2e/util_e2e/utility_simple.py @@ -0,0 +1,40 @@ +# Copyright 2022 Memgraph Ltd. +# +# Use of this software is governed by the Business Source License +# included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source +# License, and you may not use this file except in compliance with the Business Source License. +# +# As of the Change Date specified in that file, in accordance with +# the Business Source License, use of this software will be governed +# by the Apache License, Version 2.0, included in the file +# licenses/APL.txt. + +import typing +import mgclient +import sys +import pytest + + +def test_does_throw_if_null_is_checked_against_in_generic_case(): + + connection = mgclient.connect(host="localhost", port=7687) + connection.autocommit = True + + 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""" + + with pytest.raises(mgclient.DatabaseError) as err: + cursor.execute(query) + + error_msg = err.value.args[0] + assert error_msg == "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..73e294443 --- /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: "Utility simple" + binary: "tests/e2e/pytest_runner.sh" + args: ["util_e2e/utility_simple.py"] + <<: *template_cluster