Module: Restate::Testing

Defined in:
lib/restate/testing.rb

Overview

Test harness for running Restate services with a real Restate server. Opt-in via ‘require “restate/testing”` (not loaded by default).

Requires Docker and the testcontainers-core gem.

Block-based (recommended):

Restate::Testing.start(Greeter, Counter) do |env|
  env.ingress_url  # => "http://localhost:32771"
  env.admin_url    # => "http://localhost:32772"
end

Manual lifecycle (for RSpec before/after hooks):

harness = Restate::Testing::RestateTestHarness.new(Greeter, Counter)
harness.start
harness.ingress_url
harness.stop

Defined Under Namespace

Classes: RestateContainer, RestateTestHarness

Class Method Summary collapse

Class Method Details

.start(*services, **options) ⇒ Object

Starts a Restate test environment with the given services. When a block is given, stops automatically on block exit. Without a block, returns the harness for manual lifecycle management.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/restate/testing.rb', line 32

def self.start(*services, **options)
  harness = RestateTestHarness.new(*services, **options)
  harness.start

  if block_given?
    begin
      yield harness
    ensure
      harness.stop
    end
  else
    harness
  end
end