Class: TC_Mysql2
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- TC_Mysql2
- Defined in:
- ext/test.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #teardown ⇒ Object
- #test_affected_rows ⇒ Object
- #test_autocommit ⇒ Object
-
#test_more_results_next_result ⇒ Object
def test_ssl_set() end.
- #test_query_with_result ⇒ Object
- #test_reconnect ⇒ Object
- #test_set_server_option ⇒ Object
- #test_sqlstate ⇒ Object
Instance Method Details
#setup ⇒ Object
97 98 99 100 101 102 103 104 |
# File 'ext/test.rb', line 97 def setup() @host, @user, @pass, db, port, sock, flag = ARGV @db = db || "test" @port = port.to_i @sock = sock.nil? || sock.empty? ? nil : sock @flag = flag.to_i @m = Mysql.new(@host, @user, @pass, @db, @port, @sock, @flag) end |
#teardown ⇒ Object
105 106 107 |
# File 'ext/test.rb', line 105 def teardown() @m.close end |
#test_affected_rows ⇒ Object
109 110 111 112 113 |
# File 'ext/test.rb', line 109 def test_affected_rows() @m.query("create temporary table t (id int)") @m.query("insert into t values (1)") assert_equal(1, @m.affected_rows) end |
#test_autocommit ⇒ Object
115 116 117 118 119 120 |
# File 'ext/test.rb', line 115 def test_autocommit() if @m.methods.include? "autocommit" then assert_equal(@m, @m.autocommit(true)) assert_equal(@m, @m.autocommit(false)) end end |
#test_more_results_next_result ⇒ Object
def test_ssl_set()
end
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'ext/test.rb', line 125 def test_more_results_next_result() if @m.server_version >= 40100 then @m.query_with_result = false @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON) if defined? Mysql::OPTION_MULTI_STATEMENTS_ON @m.query("select 1,2,3; select 4,5,6") res = @m.store_result assert_equal(["1","2","3"], res.fetch_row) assert_equal(nil, res.fetch_row) assert_equal(true, @m.more_results) assert_equal(true, @m.more_results?) assert_equal(true, @m.next_result) res = @m.store_result assert_equal(["4","5","6"], res.fetch_row) assert_equal(nil, res.fetch_row) assert_equal(false, @m.more_results) assert_equal(false, @m.more_results?) assert_equal(false, @m.next_result) end end |
#test_query_with_result ⇒ Object
160 161 162 163 164 165 166 |
# File 'ext/test.rb', line 160 def test_query_with_result() assert_equal(true, @m.query_with_result) assert_equal(false, @m.query_with_result = false) assert_equal(false, @m.query_with_result) assert_equal(true, @m.query_with_result = true) assert_equal(true, @m.query_with_result) end |
#test_reconnect ⇒ Object
168 169 170 171 172 173 174 |
# File 'ext/test.rb', line 168 def test_reconnect() assert_equal(false, @m.reconnect) assert_equal(true, @m.reconnect = true) assert_equal(true, @m.reconnect) assert_equal(false, @m.reconnect = false) assert_equal(false, @m.reconnect) end |
#test_set_server_option ⇒ Object
145 146 147 148 149 150 |
# File 'ext/test.rb', line 145 def test_set_server_option() if @m.server_version >= 40101 then assert_equal(@m, @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON)) assert_equal(@m, @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_OFF)) end end |
#test_sqlstate ⇒ Object
152 153 154 155 156 157 158 |
# File 'ext/test.rb', line 152 def test_sqlstate() if @m.server_version >= 40100 then assert_equal("00000", @m.sqlstate) assert_raises(Mysql::Error){@m.query("hogehoge")} assert_equal("42000", @m.sqlstate) end end |