In Files

Parent

TC_Mysql2

Public Instance Methods

setup() click to toggle source
     # File test.rb, line 97
 97:   def setup()
 98:     @host, @user, @pass, db, port, sock, flag = ARGV
 99:     @db = db || "test"
100:     @port = port.to_i
101:     @sock = sock.nil? || sock.empty? ? nil : sock
102:     @flag = flag.to_i
103:     @m = Mysql.new(@host, @user, @pass, @db, @port, @sock, @flag)
104:   end
teardown() click to toggle source
     # File test.rb, line 105
105:   def teardown()
106:     @m.close if @m
107:   end
test_affected_rows() click to toggle source
     # File test.rb, line 109
109:   def test_affected_rows()
110:     @m.query("create temporary table t (id int)")
111:     @m.query("insert into t values (1)")
112:     assert_equal(1, @m.affected_rows)
113:   end
test_autocommit() click to toggle source
     # File test.rb, line 115
115:   def test_autocommit()
116:     if @m.methods.include? "autocommit" then
117:       assert_equal(@m, @m.autocommit(true))
118:       assert_equal(@m, @m.autocommit(false))
119:     end
120:   end
test_more_results_next_result() click to toggle source

def test_ssl_set() end

     # File test.rb, line 125
125:   def test_more_results_next_result()
126:     if @m.server_version >= 40100 then
127:       @m.query_with_result = false
128:       @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON) if defined? Mysql::OPTION_MULTI_STATEMENTS_ON
129:       @m.query("select 1,2,3; select 4,5,6")
130:       res = @m.store_result
131:       assert_equal(["1","2","3"], res.fetch_row)
132:       assert_equal(nil, res.fetch_row)
133:       assert_equal(true, @m.more_results)
134:       assert_equal(true, @m.more_results?)
135:       assert_equal(true, @m.next_result)
136:       res = @m.store_result
137:       assert_equal(["4","5","6"], res.fetch_row)
138:       assert_equal(nil, res.fetch_row)
139:       assert_equal(false, @m.more_results)
140:       assert_equal(false, @m.more_results?)
141:       assert_equal(false, @m.next_result)
142:     end
143:   end
test_query_with_block() click to toggle source
     # File test.rb, line 145
145:   def test_query_with_block()
146:     if @m.server_version >= 40100 then
147:       @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON)
148:       expect = [["1","2","3"], ["4","5","6"]]
149:       @m.query("select 1,2,3; select 4,5,6") {|res|
150:         assert_equal(1, res.num_rows)
151:         assert_equal(expect.shift, res.fetch_row)
152:       }
153:       assert(expect.empty?)
154:       expect = [["1","2","3"], ["4","5","6"]]
155:       assert_raises(Mysql::Error) {
156:         @m.query("select 1,2,3; hoge; select 4,5,6") {|res|
157:           assert_equal(1, res.num_rows)
158:           assert_equal(expect.shift, res.fetch_row)
159:         }
160:       }
161:       assert_equal(1, expect.size)
162:       expect = [["1","2","3"], ["4","5","6"]]
163:       assert_raises(Mysql::Error) {
164:         @m.query("select 1,2,3; select 4,5,6; hoge") {|res|
165:           assert_equal(1, res.num_rows)
166:           assert_equal(expect.shift, res.fetch_row)
167:         }
168:       }
169:       assert(expect.empty?)
170:     end
171:   end
test_query_with_block_single() click to toggle source
     # File test.rb, line 173
173:   def test_query_with_block_single()
174:     @m.query("select 1,2,3") {|res|
175:       assert_equal(1, res.num_rows)
176:       assert_equal(["1","2","3"], res.fetch_row)
177:     }
178:   end
test_query_with_result() click to toggle source
     # File test.rb, line 195
195:   def test_query_with_result()
196:     assert_equal(true, @m.query_with_result)
197:     assert_equal(false, @m.query_with_result = false)
198:     assert_equal(false, @m.query_with_result)
199:     assert_equal(true, @m.query_with_result = true)
200:     assert_equal(true, @m.query_with_result)
201:   end
test_reconnect() click to toggle source
     # File test.rb, line 203
203:   def test_reconnect()
204:     assert_equal(false, @m.reconnect)
205:     assert_equal(true, @m.reconnect = true)
206:     assert_equal(true, @m.reconnect)
207:     assert_equal(false, @m.reconnect = false)
208:     assert_equal(false, @m.reconnect)
209:   end
test_set_server_option() click to toggle source
     # File test.rb, line 180
180:   def test_set_server_option()
181:     if @m.server_version >= 40101 then
182:       assert_equal(@m, @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON))
183:       assert_equal(@m, @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_OFF))
184:     end
185:   end
test_sqlstate() click to toggle source
     # File test.rb, line 187
187:   def test_sqlstate()
188:     if @m.server_version >= 40100 then
189:       assert_equal("00000", @m.sqlstate)
190:       assert_raises(Mysql::Error){@m.query("hogehoge")}
191:       assert_equal("42000", @m.sqlstate)
192:     end
193:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.