File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,8 +6,13 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
66gemspec
77
88group :development , :test do
9+ if ENV [ 'DB_TEST' ] == 'mssql'
10+ gem 'activerecord-sqlserver-adapter' , '7.0.3.0'
11+ gem 'tiny_tds'
12+ end
913 gem 'mysql2' if ENV [ 'DB_TEST' ] == 'mysql'
1014 gem 'pg' if [ 'postgres' , 'postgresql' ] . include? ENV [ 'DB_TEST' ]
15+
1116 gem 'simplecov'
1217 gem 'simplecov-lcov'
1318
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ FROM ruby:3.2-slim
33ARG DB_TEST
44
55RUN apt-get update
6- RUN apt-get install --no-install-recommends -y build-essential curl file git nano netcat-traditional libmariadb-dev libpq-dev openssl tzdata
6+ RUN apt-get install --no-install-recommends -y build-essential curl file freetds-dev freetds-bin git nano netcat-traditional libmariadb-dev libpq-dev openssl tzdata
77
88# App setup
99WORKDIR /usr/src/app
Original file line number Diff line number Diff line change 22version : " 3.3"
33
44x-defaults :
5+ tests_mssql : &tests_mssql
6+ environment :
7+ CI : 1
8+ DB_TEST : mssql
9+ DB_PORT : 1433
10+ MSSQL_DB_HOST : mssql
11+ MSSQL_DB_NAME : test_db
12+ MSSQL_DB_USERNAME : sa
13+ MSSQL_DB_PASSWORD : Pa%%w0rd
14+ RAILS : ' 7.0'
15+ RAILS_ENV : test
16+ command :
17+ - sh
18+ - -c
19+ - |
20+ while ! nc -z $${DB_TEST} $${DB_PORT} </dev/null
21+ do echo "Waiting for DB ($${DB_TEST})..." && sleep 5; done
22+ echo "DB is now available!"
23+ cd spec/dummy70
24+ bin/setup
25+ cd ../..
26+ bin/rspec
27+ volumes :
28+ - ..:/usr/src/app:delegated
29+ depends_on :
30+ - mssql
31+
532 tests_mysql : &tests_mysql
633 environment :
734 CI : 1
@@ -57,17 +84,24 @@ x-defaults:
5784 - postgres
5885
5986services :
60- postgres :
61- image : postgres
87+ mssql :
88+ image : mcr.microsoft.com/mssql/server:2022-latest
89+ platform : linux/amd64
6290 environment :
63- POSTGRES_PASSWORD : password
91+ ACCEPT_EULA : ' Y'
92+ SA_PASSWORD : Pa%%w0rd
6493
6594 mysql :
6695 image : mysql
6796 platform : linux/amd64
6897 environment :
6998 MYSQL_ROOT_PASSWORD : password
7099
100+ postgres :
101+ image : postgres
102+ environment :
103+ POSTGRES_PASSWORD : password
104+
71105 tests_30_mysql :
72106 << : *tests_mysql
73107 build :
@@ -84,6 +118,14 @@ services:
84118 args :
85119 DB_TEST : postgres
86120
121+ tests_32_mssql :
122+ << : *tests_mssql
123+ build :
124+ context : ..
125+ dockerfile : extra/Dockerfile_32
126+ args :
127+ DB_TEST : mssql
128+
87129 tests_32_mysql :
88130 << : *tests_mysql
89131 build :
Original file line number Diff line number Diff line change 11<% case ENV['DB_TEST']
2- when 'mysql' % >
2+ when 'mssql' % >
3+ test : &test
4+ adapter : sqlserver
5+ host : <%= ENV.fetch('MSSQL_DB_HOST') { '127.0.0.1' } %>
6+ # port: <%= ENV.fetch('MSSQL_DB_PORT') { 1433 } %>
7+ database : <%= ENV.fetch('MSSQL_DB_NAME') { ver = ENV.fetch('RAILS', '').tr('.', ''); "active_storage_db_#{ver}-test" } %>
8+ username : <%= ENV.fetch('MSSQL_DB_USERNAME') { '' } %>
9+ password : <%= ENV.fetch('MSSQL_DB_PASSWORD') { '' } %>
10+ encoding : utf8
11+ pool : <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>
12+ <% when 'mysql' % >
313test : &test
414 adapter : mysql2
515 host : <%= ENV.fetch('MYSQL_DB_HOST') { '127.0.0.1' } %>
You can’t perform that action at this time.
0 commit comments