Documentation
¶
Index ¶
Constants ¶
const ( RESTATE_ADMIN_ENDPOINT_PORT = "9070" RESTATE_INGRESS_ENDPOINT_PORT = "8080" )
Variables ¶
var DisableRestateLogs = func(c *testEnvironmentConfig) { c.followLogs = false }
DisableRestateLogs disables restate log output
Functions ¶
This section is empty.
Types ¶
type TestEnvironment ¶
type TestEnvironment struct {
// contains filtered or unexported fields
}
func Start ¶
func Start(t *testing.T, services ...restate.ServiceDefinition) *TestEnvironment
Start creates a test environment with Restate using testcontainers. It automatically: - Sets up an HTTP server for the provided Restate services - Starts a Restate container using testcontainers - Registers the services with Restate - Configures automatic cleanup at the end of the test
The returned TestEnvironment provides access to the ingress client and ports for interacting with Restate during tests. For more options, use StartWithOptions.
Example:
func TestMyService(t *testing.T) {
tEnv := Start(t, restate.Reflect(Greeter{}))
client := tEnv.Ingress()
out, err := ingress.Service[string, string](client, "Greeter", "Greet").Request(t.Context(), "Francesco")
require.NoError(t, err)
require.Equal(t, "You said hi to Francesco!", out)
}
func StartWithOptions ¶
func StartWithOptions(t *testing.T, restateSrv *server.Restate, opts ...TestEnvironmentOption) *TestEnvironment
StartWithOptions creates a test environment with Restate using testcontainers, with custom configuration. It automatically: - Sets up an HTTP server for the provided Restate server - Starts a Restate container using testcontainers - Registers the services with Restate - Configures automatic cleanup at the end of the test (both HTTP server and container)
Options allow you to customize the Restate container (e.g., image version, environment variables). The returned TestEnvironment provides access to the ingress client and ports for interacting with Restate during tests.
func (*TestEnvironment) AdminPort ¶
func (tEnv *TestEnvironment) AdminPort() int
func (*TestEnvironment) Ingress ¶
func (tEnv *TestEnvironment) Ingress() *ingress.Client
func (*TestEnvironment) IngressPort ¶
func (tEnv *TestEnvironment) IngressPort() int
type TestEnvironmentOption ¶
type TestEnvironmentOption func(*testEnvironmentConfig)
TestEnvironmentOption is a function that configures a TestEnvironment
func WithRestateEnv ¶
func WithRestateEnv(env map[string]string) TestEnvironmentOption
WithRestateEnv adds environment variables for the Restate service container
func WithRestateImage ¶
func WithRestateImage(image string) TestEnvironmentOption
WithRestateImage sets the Restate container image