Skip to content

Commit

Permalink
#37 check logging
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Sep 4, 2023
1 parent 59b5321 commit 9e6d361
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/test_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ def test_basic
end
end

def test_logs_sql
log = Loog::Buffer.new
bootstrap(log: log) do |pool|
pool.exec(
'INSERT INTO book (title) VALUES ($1)',
['Object Thinking']
)
assert(log.to_s.include?('INSERT INTO book (title) VALUES ($1)'))
end
end

def test_transaction
bootstrap do |pool|
id = pool.transaction do |t|
Expand Down Expand Up @@ -116,7 +127,7 @@ def test_reconnects_on_pg_reboot

private

def bootstrap
def bootstrap(log: Loog::VERBOSE)
Dir.mktmpdir 'test' do |dir|
id = rand(100..999)
Pgtk::PgsqlTask.new("pgsql#{id}") do |t|
Expand All @@ -136,7 +147,7 @@ def bootstrap
Rake::Task["liquibase#{id}"].invoke
pool = Pgtk::Pool.new(
Pgtk::Wire::Yaml.new(File.join(dir, 'cfg.yml')),
log: Loog::VERBOSE
log: log
)
pool.start(1)
yield pool
Expand Down

0 comments on commit 9e6d361

Please sign in to comment.