From 8e0e46d7785a0c58f92edc9bb81e06c592d8b745 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Sat, 17 Dec 2022 17:13:33 +0100 Subject: [PATCH 1/3] fix test_embed_struct in test_read_only.rb --- test/test_read_only.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/test_read_only.rb b/test/test_read_only.rb index 4496c463..268f7c86 100644 --- a/test/test_read_only.rb +++ b/test/test_read_only.rb @@ -39,11 +39,17 @@ def test_struct_find end def test_embed_struct - skip "not yet" + students = Student.where(enrolled: [university: [name: "Stanford"]]) .include(:name) - .include(enrolled: [:name, university: [ :address ]]) + .include(enrolled: [:name, university: [ :address, :name ]]) .read_only.all + + assert_equal 3, students.size + students.each do |st| + assert st.enrolled.any? {|e| e.is_a?(Struct) && e.university.name.eql?('Stanford')} + end + end end end From 361940a81fb4ca1bc9f85c2ee12c6d375dfc53b6 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Sat, 17 Dec 2022 17:15:55 +0100 Subject: [PATCH 2/3] fix test_reentrant_queries by ensuring the write thread is still alive --- test/test_chunks_write.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/test_chunks_write.rb b/test/test_chunks_write.rb index a7988d40..4f0a8676 100644 --- a/test/test_chunks_write.rb +++ b/test/test_chunks_write.rb @@ -71,7 +71,6 @@ def test_put_delete_data end def test_reentrant_queries - skip "TODO: why does this test fail?" ntriples_file_path = "./test/data/nemo_ontology.ntriples" # Bypass in chunks @@ -87,8 +86,8 @@ def test_reentrant_queries tput = Thread.new { Goo.sparql_data_client.put_triples(ONT_ID_EXTRA, ntriples_file_path, mime_type="application/x-turtle") + sleep(1.5) } - sleep(1.5) count_queries = 0 tq = Thread.new { 5.times do @@ -112,8 +111,8 @@ def test_reentrant_queries tdelete = Thread.new { Goo.sparql_data_client.delete_graph(ONT_ID_EXTRA) + sleep(1.5) } - sleep(1.5) count_queries = 0 tq = Thread.new { 5.times do From a30af42241aa4d9f1ac237ea88942db3cad0765f Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Sat, 17 Dec 2022 17:16:29 +0100 Subject: [PATCH 3/3] update test_inverse_on_collection test --- test/test_collections.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/test_collections.rb b/test/test_collections.rb index 390ad349..2177c669 100644 --- a/test/test_collections.rb +++ b/test/test_collections.rb @@ -91,18 +91,18 @@ def test_unique_per_collection def test_inverse_on_collection skip "Not supported inverse on collection" - john = User.find("John").include(:name).first || - User.new(name: "John").save() + john = User.find("John").include(:name).first || User.new(name: "John").save + 5.times do |i| - Issue.new(description: "issue_#{i}", owner: john).save + Issue.find("issue_#{i}").in(john) || Issue.new(description: "issue_#{i}", owner: john).save end - - binding.pry - User.find("John",include: [:issues]).first.issues - User.find("John",include: [issues: [:desciption]]).first.issues - 5.times do |i| - Issue.find("issue_#{i}", collection: john).delete + issues = User.find("John").include(:issues).first.issues + assert_equal 5, issues.size + + issues.each do |issue| + assert_equal "issue_#{i}", issue.description + assert_equal john, issue.collection end end