Skip to content

Commit 6bf04fa

Browse files
committed
Assert server state when creating and closing prepared statements
Follow-up to eca73fe
1 parent f9b59d0 commit 6bf04fa

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

spec/mysql2/statement_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
it "should create a statement" do
1010
statement = nil
11-
expect { statement = @client.prepare 'SELECT 1' }.not_to raise_error
11+
expect { statement = @client.prepare 'SELECT 1' }.to change {
12+
@client.query("SHOW STATUS LIKE 'Prepared_stmt_count'").first['Value'].to_i
13+
}.by(1)
1214
expect(statement).to be_an_instance_of(Mysql2::Statement)
1315
end
1416

@@ -668,7 +670,9 @@
668670
context 'close' do
669671
it 'should free server resources' do
670672
stmt = @client.prepare 'SELECT 1'
671-
expect(stmt.close).to eq nil
673+
expect { stmt.close }.to change {
674+
@client.query("SHOW STATUS LIKE 'Prepared_stmt_count'").first['Value'].to_i
675+
}.by(-1)
672676
end
673677

674678
it 'should raise an error on subsequent execution' do

0 commit comments

Comments
 (0)