Class TC_Mysql2
In: test.rb
Parent: Test::Unit::TestCase

Methods

Public Instance methods

[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

[Source]

     # File test.rb, line 105
105:   def teardown()
106:     @m.close
107:   end

[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

[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

def test_ssl_set() end

[Source]

     # 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

[Source]

     # File test.rb, line 160
160:   def test_query_with_result()
161:     assert_equal(true, @m.query_with_result)
162:     assert_equal(false, @m.query_with_result = false)
163:     assert_equal(false, @m.query_with_result)
164:     assert_equal(true, @m.query_with_result = true)
165:     assert_equal(true, @m.query_with_result)
166:   end

[Source]

     # File test.rb, line 168
168:   def test_reconnect()
169:     assert_equal(false, @m.reconnect)
170:     assert_equal(true, @m.reconnect = true)
171:     assert_equal(true, @m.reconnect)
172:     assert_equal(false, @m.reconnect = false)
173:     assert_equal(false, @m.reconnect)
174:   end

[Source]

     # File test.rb, line 145
145:   def test_set_server_option()
146:     if @m.server_version >= 40101 then
147:       assert_equal(@m, @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON))
148:       assert_equal(@m, @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_OFF))
149:     end
150:   end

[Source]

     # File test.rb, line 152
152:   def test_sqlstate()
153:     if @m.server_version >= 40100 then
154:       assert_equal("00000", @m.sqlstate)
155:       assert_raises(Mysql::Error){@m.query("hogehoge")}
156:       assert_equal("42000", @m.sqlstate)
157:     end
158:   end

[Validate]