Skip to content

Instantly share code, notes, and snippets.

@Vagab
Last active July 23, 2024 17:42
Show Gist options
  • Select an option

  • Save Vagab/8856cfe9fb0565526b5f6ee24b47a010 to your computer and use it in GitHub Desktop.

Select an option

Save Vagab/8856cfe9fb0565526b5f6ee24b47a010 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails", "~> 7.2.0.beta3"
gem "pg"
gem "async"
end
require "active_record"
require "minitest/autorun"
require "async/barrier"
require "async/semaphore"
# create db on a mac
%x(psql -c 'create database thingy;')
ActiveRecord::Base.establish_connection(adapter: "postgresql", database: "thingy")
ActiveRecord::Base.logger = Logger.new(STDOUT)
class BugTest < Minitest::Test
def test_error
assert_raises(NoMethodError) do
Sync do
barrier = Async::Barrier.new
s = Async::Semaphore.new(10, parent: barrier)
1.upto(10).map do |i|
s.async do
ActiveRecord::Base.connection.execute("select pg_sleep(1);")
end
end
barrier.wait
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment