dbd-sqlanywhere 0.1.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +21 -12
- data/LICENSE +23 -23
- data/README +150 -150
- data/lib/dbd/SQLAnywhere.rb +176 -176
- data/lib/dbd/sqlanywhere/database.rb +266 -255
- data/lib/dbd/sqlanywhere/driver.rb +108 -102
- data/lib/dbd/sqlanywhere/statement.rb +216 -211
- data/test/dbd/sqlanywhere/base.rb +26 -26
- data/test/dbd/sqlanywhere/down.sql +19 -19
- data/test/dbd/sqlanywhere/up.sql +28 -28
- metadata +77 -67
- data/test/DBD_TESTS +0 -48
- data/test/dbd/general/test_database.rb +0 -157
- data/test/dbd/general/test_statement.rb +0 -249
- data/test/dbd/general/test_types.rb +0 -253
- data/test/ts_dbd.rb +0 -118
data/test/ts_dbd.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
# figure out what tests to run
|
2
|
-
require 'yaml'
|
3
|
-
require 'test/unit/testsuite'
|
4
|
-
require 'test/unit/ui/console/testrunner'
|
5
|
-
|
6
|
-
if File.basename(Dir.pwd) == "test"
|
7
|
-
$:.unshift('../lib')
|
8
|
-
else
|
9
|
-
$:.unshift('lib')
|
10
|
-
end
|
11
|
-
|
12
|
-
module Test::Unit::Assertions
|
13
|
-
def build_message(head, template=nil, *arguments)
|
14
|
-
template += "\n" + "DATABASE: " + dbtype
|
15
|
-
template &&= template.chomp
|
16
|
-
return AssertionMessage.new(head, template, arguments)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
module DBDConfig
|
21
|
-
@testbase = { }
|
22
|
-
@current_dbtype = nil
|
23
|
-
|
24
|
-
def self.get_config
|
25
|
-
config = nil
|
26
|
-
|
27
|
-
begin
|
28
|
-
config = YAML.load_file(File.join(ENV["HOME"], ".ruby-dbi.test-config.yaml"))
|
29
|
-
rescue Exception => e
|
30
|
-
config = { }
|
31
|
-
config["dbtypes"] = [ ]
|
32
|
-
end
|
33
|
-
|
34
|
-
return config
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.inject_sql(dbh, dbtype, file)
|
38
|
-
# splits by --- in the file, strips newlines and the semicolons.
|
39
|
-
# this way we can still manually import the file, but use it with our
|
40
|
-
# drivers for client-independent injection.
|
41
|
-
File.open(file).read.split(/\n*---\n*/, -1).collect { |x| x.gsub!(/\n/, ''); x.sub(/;\z/, '') }.each do |stmt|
|
42
|
-
tmp = STDERR.dup
|
43
|
-
STDERR.reopen('sql.log', 'a')
|
44
|
-
begin
|
45
|
-
dbh.commit rescue nil
|
46
|
-
dbh["AutoCommit"] = true rescue nil
|
47
|
-
dbh.do(stmt)
|
48
|
-
dbh.commit unless dbtype == 'sqlite3'
|
49
|
-
rescue Exception => e
|
50
|
-
tmp.puts "Error injecting '#{stmt}' for db #{dbtype}"
|
51
|
-
tmp.puts "Error: #{e.message}"
|
52
|
-
end
|
53
|
-
STDERR.reopen(tmp)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.current_dbtype
|
58
|
-
@current_dbtype
|
59
|
-
end
|
60
|
-
|
61
|
-
def self.current_dbtype=(setting)
|
62
|
-
@current_dbtype = setting
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.testbase(klass_name)
|
66
|
-
return @testbase[klass_name]
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.set_testbase(klass_name, klass)
|
70
|
-
@testbase[klass_name] = klass
|
71
|
-
end
|
72
|
-
|
73
|
-
def self.suite
|
74
|
-
@suite ||= []
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
if __FILE__ == $0
|
79
|
-
Dir.chdir("..") if File.basename(Dir.pwd) == "test"
|
80
|
-
$LOAD_PATH.unshift(File.join(Dir.pwd, "lib"))
|
81
|
-
Dir.chdir("test") rescue nil
|
82
|
-
|
83
|
-
begin
|
84
|
-
require 'dbi'
|
85
|
-
rescue LoadError => e
|
86
|
-
begin
|
87
|
-
require 'rubygems'
|
88
|
-
gem 'dbi'
|
89
|
-
require 'dbi'
|
90
|
-
rescue LoadError => e
|
91
|
-
abort "DBI must already be installed or must come with this package for tests to work."
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
Deprecate.set_action(proc { })
|
96
|
-
|
97
|
-
config = DBDConfig.get_config
|
98
|
-
|
99
|
-
config["dbtypes"] = ENV["DBTYPES"].split(/\s+/) if ENV["DBTYPES"]
|
100
|
-
|
101
|
-
if config and config["dbtypes"]
|
102
|
-
config["dbtypes"].each do |dbtype|
|
103
|
-
unless config[dbtype]
|
104
|
-
warn "#{dbtype} is selected for testing but not configured; see test/DBD_TESTS"
|
105
|
-
next
|
106
|
-
end
|
107
|
-
|
108
|
-
# base.rb is special, see DBD_TESTS
|
109
|
-
require "dbd/#{dbtype}/base.rb"
|
110
|
-
Dir["dbd/#{dbtype}/test*.rb"].each { |file| require file }
|
111
|
-
# run the general tests
|
112
|
-
DBDConfig.current_dbtype = dbtype.to_sym
|
113
|
-
Dir["dbd/general/test*.rb"].each { |file| load file; DBDConfig.suite << @class }
|
114
|
-
end
|
115
|
-
elsif !config["dbtypes"]
|
116
|
-
warn "Please see test/DBD_TESTS for information on configuring DBD tests."
|
117
|
-
end
|
118
|
-
end
|