dbd-pg 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,118 @@
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
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dbd-pg
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.3
5
+ platform: ruby
6
+ authors:
7
+ - Erik Hollensbe
8
+ - Christopher Maujean
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-08-23 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: dbi
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.4.0
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: pg
28
+ type: :runtime
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ version:
36
+ description: PostgreSQL DBI DBD
37
+ email: ruby-dbi-users@rubyforge.org
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - README
44
+ - LICENSE
45
+ - ChangeLog
46
+ files:
47
+ - test/dbd/general/test_types.rb
48
+ - test/dbd/general/test_database.rb
49
+ - test/dbd/general/test_statement.rb
50
+ - test/dbd/postgresql/test_bytea.rb
51
+ - test/dbd/postgresql/test_transactions.rb
52
+ - test/dbd/postgresql/test_ping.rb
53
+ - test/dbd/postgresql/down.sql
54
+ - test/dbd/postgresql/test_arrays.rb
55
+ - test/dbd/postgresql/testdbipg.rb
56
+ - test/dbd/postgresql/up.sql
57
+ - test/dbd/postgresql/base.rb
58
+ - test/dbd/postgresql/test_timestamp.rb
59
+ - test/dbd/postgresql/test_async.rb
60
+ - test/dbd/postgresql/test_blob.rb
61
+ - lib/dbd/Pg.rb
62
+ - lib/dbd/pg/exec.rb
63
+ - lib/dbd/pg/tuples.rb
64
+ - lib/dbd/pg/type.rb
65
+ - lib/dbd/pg/database.rb
66
+ - lib/dbd/pg/statement.rb
67
+ - test/DBD_TESTS
68
+ - README
69
+ - LICENSE
70
+ - ChangeLog
71
+ has_rdoc: true
72
+ homepage: http://www.rubyforge.org/projects/ruby-dbi
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.8.0
83
+ version:
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ requirements: []
91
+
92
+ rubyforge_project: ruby-dbi
93
+ rubygems_version: 1.2.0
94
+ signing_key:
95
+ specification_version: 2
96
+ summary: PostgreSQL DBI DBD
97
+ test_files:
98
+ - test/ts_dbd.rb