Skip to content

Commit

Permalink
add tests and add logic around where to include Trilogy adapter and c…
Browse files Browse the repository at this point in the history
…onnection
  • Loading branch information
zmariscal committed Feb 3, 2024
1 parent 5b97fd6 commit 35e6ab5
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:5.7
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: github
MYSQL_PASSWORD: github
MYSQL_DATABASE: activerecord_import_test
options: >-
--health-cmd "mysqladmin ping -h localhost"
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -110,6 +124,9 @@ jobs:
run: |
bundle exec rake test:spatialite
bundle exec rake test:sqlite3
- name: Run trilogy tests
if: ${{ matrix.env.AR_VERSION >= '7.0' }}
run: bundle exec rake test:trilogy
lint:
runs-on: ubuntu-latest
env:
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ADAPTERS = %w(
sqlite3
spatialite
seamless_database_pool
trilogy
).freeze
ADAPTERS.each do |adapter|
namespace :test do
Expand Down
11 changes: 11 additions & 0 deletions test/adapters/trilogy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

# ensure we connect to the trilogy adapter
if ENV['AR_VERSION'].to_f >= 7.1
ENV["ARE_DB"] = "trilogy"
else
require "activerecord-trilogy-adapter"
require "trilogy_adapter/connection"
ActiveRecord::Base.extend TrilogyAdapter::Connection
ENV["ARE_DB"] = "trilogy"
end
5 changes: 5 additions & 0 deletions test/database.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ sqlite3: &sqlite3

spatialite:
<<: *sqlite3

trilogy:
<<: *common
adapter: trilogy
host: mysql
4 changes: 4 additions & 0 deletions test/github/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ sqlite3: &sqlite3

spatialite:
<<: *sqlite3

trilogy:
<<: *common
adapter: trilogy
7 changes: 7 additions & 0 deletions test/trilogy/import_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions")
require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples")

should_support_mysql_import_functionality

0 comments on commit 35e6ab5

Please sign in to comment.