Skip to content

[test harness] consider an even simpler harness #153

@igalshilman

Description

@igalshilman
@asynccontextmanager
async def simple_harness(service: Service | VirtualObject | Workflow) -> typing.AsyncIterator[restate.RestateClient]:
    async with restate.create_test_harness(
        restate.app([service]), restate_image="ghcr.io/restatedev/restate:latest"
    ) as restate_test_harness:
        yield restate_test_harness.client

with that we can write tests that cover a single handler/serivce like that:

async def test_sanity():
    greeter = Service("greeter")

    @greeter.handler()
    async def greet(ctx: Context, name: str) -> str:
        return "hi"

    async with simple_harness(greeter) as client:
             assert "hi" == await client.service_call(greet, arg="bob")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions