Skip to content

Commit 94c102f

Browse files
committed
Make both dblib and odbc test work in isolation.
1 parent 4199be4 commit 94c102f

File tree

4 files changed

+58
-50
lines changed

4 files changed

+58
-50
lines changed

Rakefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require 'rake/rdoctask'
88
def test_libs(mode='dblib')
99
['lib',
1010
'test',
11+
"test/connections/#{mode}",
1112
"#{ENV['RAILS_SOURCE']}/activerecord/test"]
1213
end
1314

@@ -21,7 +22,6 @@ def test_files
2122
files
2223
end
2324

24-
2525
task :test => ['test:dblib']
2626
task :default => [:test]
2727

@@ -30,7 +30,6 @@ namespace :test do
3030
['dblib','odbc'].each do |mode|
3131

3232
Rake::TestTask.new(mode) do |t|
33-
ENV.send :[]=, 'ARCONN', mode
3433
t.libs = test_libs(mode)
3534
t.test_files = test_files
3635
t.verbose = true
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module ARTest
2+
def self.sqlserver_connection_name
3+
'dblib'
4+
end
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module ARTest
2+
def self.sqlserver_connection_name
3+
'odbc'
4+
end
5+
end

test/support/config.rb

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,58 @@
1+
require 'connection_name'
2+
13
module ARTest
24

3-
class << self
4-
5-
def config
6-
@config ||= {
5+
def self.config
6+
@config ||= {
7+
8+
'default_connection' => sqlserver_connection_name,
9+
10+
'connections' => {
711

8-
'default_connection' => 'dblib',
12+
'dblib' => {
13+
'arunit' => {
14+
'adapter' => 'sqlserver',
15+
'mode' => 'dblib',
16+
'dataserver' => ENV['ACTIVERECORD_UNITTEST_DATASERVER'],
17+
'username' => ENV['ACTIVERECORD_UNITTEST_USER'] || 'rails',
18+
'password' => ENV['ACTIVERECORD_UNITTEST_PASS'] || '',
19+
'database' => 'activerecord_unittest',
20+
'appname' => 'SQLServerAdptrUnit',
21+
'azure' => !ENV['ACTIVERECORD_UNITTEST_AZURE'].nil?
22+
},
23+
'arunit2' => {
24+
'adapter' => 'sqlserver',
25+
'mode' => 'dblib',
26+
'dataserver' => ENV['ACTIVERECORD_UNITTEST_DATASERVER'],
27+
'username' => ENV['ACTIVERECORD_UNITTEST_USER'] || 'rails',
28+
'password' => ENV['ACTIVERECORD_UNITTEST_PASS'] || '',
29+
'database' => 'activerecord_unittest2',
30+
'appname' => 'SQLServerAdptrUnit2',
31+
'azure' => !ENV['ACTIVERECORD_UNITTEST_AZURE'].nil?
32+
}
33+
},
934

10-
'connections' => {
11-
12-
'dblib' => {
13-
'arunit' => {
14-
'adapter' => 'sqlserver',
15-
'mode' => 'dblib',
16-
'dataserver' => ENV['ACTIVERECORD_UNITTEST_DATASERVER'],
17-
'username' => ENV['ACTIVERECORD_UNITTEST_USER'] || 'rails',
18-
'password' => ENV['ACTIVERECORD_UNITTEST_PASS'] || '',
19-
'database' => 'activerecord_unittest',
20-
'appname' => 'SQLServerAdptrUnit',
21-
'azure' => !ENV['ACTIVERECORD_UNITTEST_AZURE'].nil?
22-
},
23-
'arunit2' => {
24-
'adapter' => 'sqlserver',
25-
'mode' => 'dblib',
26-
'dataserver' => ENV['ACTIVERECORD_UNITTEST_DATASERVER'],
27-
'username' => ENV['ACTIVERECORD_UNITTEST_USER'] || 'rails',
28-
'password' => ENV['ACTIVERECORD_UNITTEST_PASS'] || '',
29-
'database' => 'activerecord_unittest2',
30-
'appname' => 'SQLServerAdptrUnit2',
31-
'azure' => !ENV['ACTIVERECORD_UNITTEST_AZURE'].nil?
32-
}
35+
'odbc' => {
36+
'arunit' => {
37+
'adapter' => 'sqlserver',
38+
'mode' => 'odbc',
39+
'host' => 'localhost',
40+
'username' => 'rails',
41+
'dsn' => ENV['ACTIVERECORD_UNITTEST_DSN'] || 'activerecord_unittest',
42+
'database' => 'activerecord_unittest'
3343
},
34-
35-
'odbc' => {
36-
'arunit' => {
37-
'adapter' => 'sqlserver',
38-
'mode' => 'ODBC',
39-
'host' => 'localhost',
40-
'username' => 'rails',
41-
'dsn' => ENV['ACTIVERECORD_UNITTEST_DSN'] || 'activerecord_unittest',
42-
'database' => 'activerecord_unittest'
43-
},
44-
'arunit2' => {
45-
'adapter' => 'sqlserver',
46-
'mode' => 'ODBC',
47-
'host' => 'localhost',
48-
'username' => 'rails',
49-
'dsn' => ENV['ACTIVERECORD_UNITTEST2_DSN'] || 'activerecord_unittest2',
50-
'database' => 'activerecord_unittest2'
51-
}
44+
'arunit2' => {
45+
'adapter' => 'sqlserver',
46+
'mode' => 'odbc',
47+
'host' => 'localhost',
48+
'username' => 'rails',
49+
'dsn' => ENV['ACTIVERECORD_UNITTEST2_DSN'] || 'activerecord_unittest2',
50+
'database' => 'activerecord_unittest2'
5251
}
53-
5452
}
53+
5554
}
56-
end
55+
}
5756

5857
end
5958
end

0 commit comments

Comments
 (0)