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

Methods

Public Instance methods

[Source]

     # File test.rb, line 93
 93:   def setup()
 94:     @host, @user, @pass, db, port, sock, flag = ARGV
 95:     @db = db || "test"
 96:     @port = port.to_i
 97:     @sock = sock.nil? || sock.empty? ? nil : sock
 98:     @flag = flag.to_i
 99:     @m = Mysql.new(@host, @user, @pass, @db, @port, @sock, @flag)
100:   end

[Source]

     # File test.rb, line 101
101:   def teardown()
102:     @m.close
103:   end

[Source]

     # File test.rb, line 105
105:   def test_affected_rows()
106:     @m.query("create temporary table t (id int)")
107:     @m.query("insert into t values (1)")
108:     assert_equal(1, @m.affected_rows)
109:   end

[Source]

     # File test.rb, line 111
111:   def test_autocommit()
112:     if @m.methods.include? "autocommit" then
113:       assert_equal(@m, @m.autocommit(true))
114:       assert_equal(@m, @m.autocommit(false))
115:     end
116:   end

def test_ssl_set() end

[Source]

     # File test.rb, line 121
121:   def test_more_results_next_result()
122:     if @m.methods.include? "more_results" then
123:       @m.query_with_result = false
124:       @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON)
125:       @m.query("select 1,2,3; select 4,5,6")
126:       res = @m.store_result
127:       assert_equal(["1","2","3"], res.fetch_row)
128:       assert_equal(nil, res.fetch_row)
129:       assert_equal(true, @m.more_results)
130:       assert_equal(true, @m.more_results?)
131:       assert_equal(true, @m.next_result)
132:       res = @m.store_result
133:       assert_equal(["4","5","6"], res.fetch_row)
134:       assert_equal(nil, res.fetch_row)
135:       assert_equal(false, @m.more_results)
136:       assert_equal(false, @m.more_results?)
137:       assert_equal(false, @m.next_result)
138:     end
139:   end

[Source]

     # File test.rb, line 152
152:   def test_query_with_result()
153:     assert_equal(true, @m.query_with_result)
154:     assert_equal(false, @m.query_with_result = false)
155:     assert_equal(false, @m.query_with_result)
156:     assert_equal(true, @m.query_with_result = true)
157:     assert_equal(true, @m.query_with_result)
158:   end

[Source]

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

[Source]

     # File test.rb, line 141
141:   def test_set_server_option()
142:     assert_equal(@m, @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_ON))
143:     assert_equal(@m, @m.set_server_option(Mysql::OPTION_MULTI_STATEMENTS_OFF))
144:   end

[Source]

     # File test.rb, line 146
146:   def test_sqlstate()
147:     assert_equal("00000", @m.sqlstate)
148:     assert_raises(Mysql::Error){@m.query("hogehoge")}
149:     assert_equal("42000", @m.sqlstate)
150:   end

[Validate]