diff --git a/test/test_integration.rb b/test/test_integration.rb index 360ccfb..ed1888b 100644 --- a/test/test_integration.rb +++ b/test/test_integration.rb @@ -6,8 +6,7 @@ require "pg_ephemeral" module En57 class TestIntegration < Minitest::Test SERVER = PgEphemeral.start - CONNECTION_URI = SERVER.url - CONNECTION = PG.connect(CONNECTION_URI) + CONNECTION = PG.connect(SERVER.url) Minitest.after_run do CONNECTION.close @@ -26,7 +25,7 @@ module En57 end def test_append_with_fail_if_and_no_matches_appends_events - repository = PgRepository.new(CONNECTION_URI, JsonSerializer.new) + repository = PgRepository.new(SERVER.url, JsonSerializer.new) repository.append( [Event.new(id: ids[0], type: "OrderPlaced")], @@ -44,7 +43,7 @@ module En57 end def test_append_with_fail_if_and_matches_raises_append_condition_violated - repository = PgRepository.new(CONNECTION_URI, JsonSerializer.new) + repository = PgRepository.new(SERVER.url, JsonSerializer.new) existing_event = Event.new(id: ids[0], type: "OrderPlaced") repository.append([existing_event], fail_if: Query.all, after: nil) @@ -63,7 +62,7 @@ module En57 end def test_append_with_after_ignores_matches_at_or_before_cutoff - repository = PgRepository.new(CONNECTION_URI, JsonSerializer.new) + repository = PgRepository.new(SERVER.url, JsonSerializer.new) existing_event = Event.new(id: ids[0], type: "OrderPlaced") repository.append([existing_event], fail_if: Query.all, after: nil) after = @@ -89,7 +88,7 @@ module En57 end def test_append_with_after_raises_if_match_is_after_cutoff - repository = PgRepository.new(CONNECTION_URI, JsonSerializer.new) + repository = PgRepository.new(SERVER.url, JsonSerializer.new) existing_event = Event.new(id: ids[0], type: "OrderPlaced") repository.append([existing_event], fail_if: Query.all, after: nil) @@ -226,7 +225,7 @@ module En57 def ids = @ids ||= Hash.new { |h, k| h[k] = SecureRandom.uuid_v7 } def with_event_store = - yield EventStore.new(PgRepository.new(CONNECTION_URI, JsonSerializer.new)) + yield EventStore.new(PgRepository.new(SERVER.url, JsonSerializer.new)) def setup = CONNECTION.exec("TRUNCATE TABLE tags, events RESTART IDENTITY CASCADE") diff --git a/test/test_stress.rb b/test/test_stress.rb index 5d01325..4eba3b3 100644 --- a/test/test_stress.rb +++ b/test/test_stress.rb @@ -7,8 +7,7 @@ require "test_helper" module En57 class TestStress < Minitest::Test SERVER = PgEphemeral.start - CONNECTION_URI = SERVER.url - CONNECTION = PG.connect(CONNECTION_URI) + CONNECTION = PG.connect(SERVER.url) Minitest.after_run do CONNECTION.close @@ -37,9 +36,7 @@ module En57 Array.new(worker_count) do Thread.new do store = - EventStore.new( - PgRepository.new(CONNECTION_URI, JsonSerializer.new), - ) + EventStore.new(PgRepository.new(SERVER.url, JsonSerializer.new)) barrier.wait account_scope = store.read.with_tag(account_tag) @@ -79,7 +76,7 @@ module En57 def event_store @event_store ||= - EventStore.new(PgRepository.new(CONNECTION_URI, JsonSerializer.new)) + EventStore.new(PgRepository.new(SERVER.url, JsonSerializer.new)) end def account_balance(scope)