Skip to content

Commit

Permalink
Add test for Database#with_advisory_lock :server option on PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Feb 21, 2024
1 parent f912253 commit adde5bb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spec/core/mock_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,12 @@ def a.method_missing(m, *x) push(*x) end
db.sqls.must_equal ['BEGIN', 'BEGIN -- "test"', 'SELECT * FROM a', 'SELECT * FROM t -- "test"', 'COMMIT -- "test"', 'COMMIT']
end

it "should correctly handle with_advisory_lock when sharding" do
db = Sequel.mock(:host=>'postgres', :servers=>{:test=>{}, 'test'=>{}}, :fetch=>{:v=>true})
db.with_advisory_lock(1234, server: :test){}
db.sqls.must_equal ['SELECT pg_try_advisory_lock(1234) LIMIT 1 -- test', 'SELECT pg_advisory_unlock(1234) LIMIT 1 -- test']
end

it "should yield a mock connection object from synchronize" do
c = Sequel.mock.synchronize{|conn| conn}
c.must_be_kind_of(Sequel::Mock::Connection)
Expand Down

0 comments on commit adde5bb

Please sign in to comment.