Skip to content

Commit

Permalink
Make trilogy tests pass on MariaDB
Browse files Browse the repository at this point in the history
* `supports_json?` always return false on mariadb so the test needs to
stub.
* to_a(as: :hash) is not supported on trilogy. And we should be dealing
with ActiveRecord::Result objects anyway.
  • Loading branch information
rafaelfranca committed Aug 4, 2023
1 parent 83e61ca commit 191ae49
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
@@ -1,10 +1,10 @@
GIT
remote: https://github.com/github/trilogy.git
revision: 8e4ae98569c12894da9bcbee5edb32b76068dbfd
revision: a1f46bbb79f866c157ead6d483474670bdb17334
branch: main
glob: contrib/ruby/*.gemspec
specs:
trilogy (2.4.0)
trilogy (2.4.1)

GIT
remote: https://github.com/matthewd/websocket-client-simple.git
Expand Down
Expand Up @@ -29,7 +29,9 @@ class TrilogyAdapterTest < ActiveRecord::TrilogyTestCase
end

test "#supports_json answers true without Maria DB and greater version" do
assert @conn.supports_json?
@conn.stub(:mariadb?, false) do
assert_equal true, @conn.supports_json?
end
end

test "#supports_json answers false without Maria DB and lesser version" do
Expand Down
3 changes: 1 addition & 2 deletions activerecord/test/cases/migration_test.rb
Expand Up @@ -1465,13 +1465,12 @@ def test_default_functions_on_columns
if current_adapter?(:PostgreSQLAdapter)
assert_equal "gen_random_uuid()", column(:name).default_function
Person.connection.execute("INSERT INTO delete_me DEFAULT VALUES")
person_data = Person.connection.execute("SELECT * FROM delete_me ORDER BY id DESC").to_a.first
else
assert_equal "uuid()", column(:name).default_function
Person.connection.execute("INSERT INTO delete_me () VALUES ()")
person_data = Person.connection.execute("SELECT * FROM delete_me ORDER BY id DESC").to_a(as: :hash).first
end

person_data = Person.connection.select_one("SELECT * FROM delete_me ORDER BY id DESC")
assert_match(/\A(.+)-(.+)-(.+)-(.+)\Z/, person_data.fetch("name"))
end
end
Expand Down

0 comments on commit 191ae49

Please sign in to comment.