blob: 0f1264b8cee1227435e10f36abfc5e8518121bbb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
require 'cases/helper'
module ActiveRecord
module SqlserverSetupper
def setup
@database = 'db.sqlserver'
@connection = stub :connection
@configuration = {
'adapter' => 'sqlserver',
'database' => @database,
'host' => 'localhost',
'username' => 'username',
'password' => 'password',
}
ActiveRecord::Base.stubs(:connection).returns(@connection)
ActiveRecord::Base.stubs(:establish_connection).returns(true)
@tasks = Class.new(ActiveRecord::Tasks::SqlserverDatabaseTasks) do
def initialize(configuration)
ActiveSupport::Deprecation.silence { super }
end
end
ActiveRecord::Tasks::DatabaseTasks.stubs(:class_for_adapter).returns(@tasks) unless defined? ActiveRecord::ConnectionAdapters::SQLServerAdapter
end
end
class SqlserverDBCreateTest < ActiveRecord::TestCase
include SqlserverSetupper
def test_db_retrieves_create
message = capture(:stderr) do
ActiveRecord::Tasks::DatabaseTasks.create @configuration
end
assert_match(/not supported/, message)
end
end
class SqlserverDBDropTest < ActiveRecord::TestCase
include SqlserverSetupper
def test_db_retrieves_drop
message = capture(:stderr) do
ActiveRecord::Tasks::DatabaseTasks.drop @configuration
end
assert_match(/not supported/, message)
end
end
class SqlserverDBCharsetAndCollationTest < ActiveRecord::TestCase
include SqlserverSetupper
def test_db_retrieves_collation
assert_raise NoMethodError do
ActiveRecord::Tasks::DatabaseTasks.collation @configuration
end
end
def test_db_retrieves_charset
message = capture(:stderr) do
ActiveRecord::Tasks::DatabaseTasks.charset @configuration
end
assert_match(/not supported/, message)
end
end
class SqlserverStructureDumpTest < ActiveRecord::TestCase
include SqlserverSetupper
def test_structure_dump
filename = "sqlserver.sql"
Kernel.expects(:system).with("smoscript -s localhost -d #{@database} -u username -p password -f #{filename} -A -U")
ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, filename)
end
end
class SqlserverStructureLoadTest < ActiveRecord::TestCase
include SqlserverSetupper
def test_structure_load
filename = "sqlserver.sql"
Kernel.expects(:system).with("sqlcmd -S localhost -d #{@database} -U username -P password -i #{filename}")
ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename)
end
end
end
|