From 50aef432eeed7aced32bc7b17c8da73f98717df6 Mon Sep 17 00:00:00 2001 From: Julia Kovtun Date: Wed, 4 Jun 2025 23:56:10 +0200 Subject: [PATCH 1/2] Implemented ResultSingleOptional testkit request --- .../backend/messages/requests/get_features.rb | 2 +- .../messages/requests/result_single_optional.rb | 15 +++++++++++++++ .../backend/messages/requests/start_test.rb | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 testkit-backend/lib/testkit/backend/messages/requests/result_single_optional.rb diff --git a/testkit-backend/lib/testkit/backend/messages/requests/get_features.rb b/testkit-backend/lib/testkit/backend/messages/requests/get_features.rb index 88a4fae4..170654ea 100644 --- a/testkit-backend/lib/testkit/backend/messages/requests/get_features.rb +++ b/testkit-backend/lib/testkit/backend/messages/requests/get_features.rb @@ -19,7 +19,7 @@ class GetFeatures < Request 'Feature:API:Result.List' => 'ja', 'Feature:API:Result.Peek' => 'ja', 'Feature:API:Result.Single' => 'ja', - 'Feature:API:Result.SingleOptional' => '', + 'Feature:API:Result.SingleOptional' => 'jar', 'Feature:API:RetryableExceptions' => '', 'Feature:API:Session:AuthConfig' => 'a', 'Feature:API:Session:NotificationsConfig' => 'a', diff --git a/testkit-backend/lib/testkit/backend/messages/requests/result_single_optional.rb b/testkit-backend/lib/testkit/backend/messages/requests/result_single_optional.rb new file mode 100644 index 00000000..a608d7d0 --- /dev/null +++ b/testkit-backend/lib/testkit/backend/messages/requests/result_single_optional.rb @@ -0,0 +1,15 @@ +module Testkit::Backend::Messages + module Requests + class ResultSingleOptional < Request + def process + result = fetch(result_id) + record = begin + { values: result.single.values.map(&method(:to_testkit)) } + rescue Neo4j::Driver::Exceptions::NoSuchRecordException + nil + end + named_entity('RecordOptional', record:, warnings: []) + end + end + end +end diff --git a/testkit-backend/lib/testkit/backend/messages/requests/start_test.rb b/testkit-backend/lib/testkit/backend/messages/requests/start_test.rb index 2dc8bb71..3c257ddb 100644 --- a/testkit-backend/lib/testkit/backend/messages/requests/start_test.rb +++ b/testkit-backend/lib/testkit/backend/messages/requests/start_test.rb @@ -4,6 +4,8 @@ class StartTest < Request SKIPPED_TESTS = { 'neo4j.test_direct_driver.TestDirectDriver.test_custom_resolver': 'Does not call resolver for direct connections', # skip for java hardcoded in testkit 'stub.session_run_parameters.test_session_run_parameters.TestSessionRunParameters.test_empty_query': 'rejects empty string', # skip for java hardcoded in testkit + 'stub.iteration.test_result_optional_single.TestResultSingleOptional.test_result_single_optional_with_2_records': 'Not implemented for ruby driver in testkit', + 'stub.iteration.test_result_optional_single.TestResultSingleOptional.test_result_single_optional_with_disconnect': 'Not implemented for ruby driver in testkit', # 'stub.iteration.test_iteration_tx_run.TestIterationTxRun.test_nested': 'completely pulls the first query before running the second', # 'stub.optimizations.test_optimizations.TestOptimizations.test_uses_implicit_default_arguments': 'Driver does not implement optimization for qid in explicit transaction', # 'stub.optimizations.test_optimizations.TestOptimizations.test_uses_implicit_default_arguments_multi_query': 'Driver does not implement optimization for qid in explicit transaction', From 3f720c67997279262bf6b89a63244fb3200d008f Mon Sep 17 00:00:00 2001 From: Julia Kovtun Date: Thu, 5 Jun 2025 15:24:54 +0200 Subject: [PATCH 2/2] ResultSingleOptional request refactoring --- .../backend/messages/requests/result_single_optional.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/testkit-backend/lib/testkit/backend/messages/requests/result_single_optional.rb b/testkit-backend/lib/testkit/backend/messages/requests/result_single_optional.rb index a608d7d0..b17bd4a6 100644 --- a/testkit-backend/lib/testkit/backend/messages/requests/result_single_optional.rb +++ b/testkit-backend/lib/testkit/backend/messages/requests/result_single_optional.rb @@ -2,12 +2,8 @@ module Testkit::Backend::Messages module Requests class ResultSingleOptional < Request def process - result = fetch(result_id) - record = begin - { values: result.single.values.map(&method(:to_testkit)) } - rescue Neo4j::Driver::Exceptions::NoSuchRecordException - nil - end + record = fetch(result_id).first + record = { values: record.values.map(&method(:to_testkit)) } if record named_entity('RecordOptional', record:, warnings: []) end end