Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Report for JRuby: Fiber#new still creates new Threads #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
--format documentation
--color
--require spec_helper
--tag ~with_jdbc
14 changes: 13 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ source "https://rubygems.org"
gemspec

gem "database_cleaner-core", git: "https://github.com/DatabaseCleaner/database_cleaner"
gem "byebug"

group :cruby_only do
gem "byebug"
gem "mysql2"
gem "pg"
gem "sqlite3"
end

group :development do
gem "bundler"
gem "rake"
gem "rspec"
end

group :test do
gem "simplecov", require: false
Expand Down
7 changes: 0 additions & 7 deletions database_cleaner-sequel.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,4 @@ Gem::Specification.new do |spec|

spec.add_dependency "database_cleaner-core", "~>2.0.0"
spec.add_dependency "sequel"

spec.add_development_dependency "bundler"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
spec.add_development_dependency "mysql2"
spec.add_development_dependency "pg"
spec.add_development_dependency "sqlite3"
end
117 changes: 117 additions & 0 deletions spec/database_cleaner/sequel/jdbc_transaction_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
require 'database_cleaner/sequel/transaction'
require 'database_cleaner/spec'
require 'sequel'
require 'database_cleaner/spec/database_helper'
require 'ostruct'

if RUBY_PLATFORM == 'java'
require_relative '../../support/postgresql-42.3.0.jar'

class SequelHelper < DatabaseCleaner::Spec::DatabaseHelper
private

def establish_connection(_config = default_config)
@connection = ::Sequel.connect(
# 'postgres://database_cleaner:[email protected]:5433/database_cleaner_test'
'jdbc:postgresql://127.0.0.1:5433/database_cleaner_test?user=database_cleaner&password=database_cleaner'
)
end
end
end

module DatabaseCleaner
module Sequel
RSpec.describe Transaction, :with_jdbc do
it_should_behave_like "a database_cleaner strategy"

SequelHelper.with_all_dbs do |helper|
next unless helper.db == :postgres

context "using a #{helper.db} connection" do
around do |example|
helper.setup
example.run
helper.teardown
end

let(:connection) { helper.connection }

before { subject.db = connection }

context "cleaning" do
it "should clean database" do
subject.cleaning do
connection[:users].insert
expect(connection[:users].count).to eq(1)
end

expect(connection[:users]).to be_empty
end

it "should work with nested transaction" do
subject.cleaning do
begin
connection.transaction do
connection[:users].insert
connection[:users].insert

expect(connection[:users].count).to eq(2)
raise ::Sequel::Rollback
end
rescue
end

connection[:users].insert
expect(connection[:users].count).to eq(1)
end

expect(connection[:users]).to be_empty
end
end

context "start/clean" do
it "should clean database" do
subject.start

connection[:users].insert
expect(connection[:users].count).to eq(1)

subject.clean

expect(connection[:users]).to be_empty
end

it "should work with nested transaction" do
subject.start
begin
connection.transaction do
connection[:users].insert
connection[:users].insert

expect(connection[:users].count).to eq(2)
raise ::Sequel::Rollback
end
rescue
end

connection[:users].insert
expect(connection[:users].count).to eq(1)

subject.clean

expect(connection[:users]).to be_empty
end
end
end
end

describe "start" do
it "should start a transaction"
end

describe "clean" do
it "should finish a transaction"
end
end
end
end
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "bundler/setup"
require "byebug"

if ENV['COVERAGE'] == 'true'
require "simplecov"
Expand Down
Binary file added spec/support/postgresql-42.3.0.jar
Binary file not shown.