diff --git a/test/test_event_store.rb b/test/test_event_store.rb index 1fde6fe..f37442a 100644 --- a/test/test_event_store.rb +++ b/test/test_event_store.rb @@ -6,10 +6,6 @@ module En57 class TestEventStore < Minitest::Test cover EventStore - def credit_topped_up - @credit_topped_up ||= Event.new(type: "CreditsToppedUp") - end - def test_append_event repository = Class @@ -105,5 +101,11 @@ module En57 assert_equal({ fail_if:, after: nil }, repository.kwargs) end + + private + + def credit_topped_up + @credit_topped_up ||= Event.new(type: "CreditsToppedUp") + end end end diff --git a/test/test_integration.rb b/test/test_integration.rb index 78d6c3a..360ccfb 100644 --- a/test/test_integration.rb +++ b/test/test_integration.rb @@ -14,14 +14,6 @@ module En57 SERVER.shutdown end - 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)) - - def setup = - CONNECTION.exec("TRUNCATE TABLE tags, events RESTART IDENTITY CASCADE") - def test_happy_path with_event_store do |event_store| events = [ @@ -228,5 +220,15 @@ module En57 assert_equal(events.fetch_values(0, 2), (orders | prices).each.to_a) end end + + private + + 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)) + + def setup = + CONNECTION.exec("TRUNCATE TABLE tags, events RESTART IDENTITY CASCADE") end end diff --git a/test/test_json_serializer.rb b/test/test_json_serializer.rb index 162b5e0..671aff3 100644 --- a/test/test_json_serializer.rb +++ b/test/test_json_serializer.rb @@ -11,8 +11,6 @@ module En57 class TestJsonSerializer < Minitest::Test cover JsonSerializer - def serializer = JsonSerializer.new - class Example < Data.define(:name, :value, :serialized, :klass) NATIVE_TYPES = %w[ String @@ -69,5 +67,9 @@ module En57 def test_empty_meta_for_native_payload assert_equal(%w[{"kaka":"dudu"} {}], serializer.dump("kaka" => "dudu")) end + + private + + def serializer = JsonSerializer.new end end diff --git a/test/test_stress.rb b/test/test_stress.rb index fa00685..5d01325 100644 --- a/test/test_stress.rb +++ b/test/test_stress.rb @@ -15,10 +15,6 @@ module En57 SERVER.shutdown end - def setup - CONNECTION.exec("TRUNCATE TABLE tags, events RESTART IDENTITY CASCADE") - end - def test_only_one_writer_can_consume_account_credits account_tag = "account:x" event_store.append( @@ -77,6 +73,10 @@ module En57 private + def setup + CONNECTION.exec("TRUNCATE TABLE tags, events RESTART IDENTITY CASCADE") + end + def event_store @event_store ||= EventStore.new(PgRepository.new(CONNECTION_URI, JsonSerializer.new))