Skip to content

[Go SDK] Test helpers + fixture library #515

@santoshkumarradha

Description

@santoshkumarradha

Summary

Add Go test helpers and a captured-fixture library so reasoners can be unit-tested without spinning up a control plane, mirroring the Python agentfield/testing.py surface.

Part of the epic #508.

Scope

New Files

File Purpose
sdk/go/triggers/testing.go SimulateEvent(t, handler, fixture) and SimulateSchedule(t, handler, opts) — build a *triggers.Context from a fixture and invoke the handler in the same shape the dispatch path uses
sdk/go/triggers/testdata/*.json Captured payload library — copied from sdk/python/agentfield/fixtures/triggers/ so behavioural parity is provable against the same JSON files
sdk/go/triggers/load_fixture.go LoadFixture(t, name) — small helper that opens testdata/name and unmarshals into the dispatcher envelope shape

Interface

import "github.com/Agent-Field/agentfield/sdk/go/triggers"

func TestHandlePayment(t *testing.T) {
    fixture := triggers.LoadFixture(t, "stripe.payment_intent.succeeded.json")
    result, err := triggers.SimulateEvent(t, handlePayment, fixture)
    if err != nil { t.Fatal(err) }
    if result.(map[string]any)["kind"] != "payment" {
        t.Fatalf("expected payment kind, got %v", result)
    }
}

Acceptance

  • go test -race ./sdk/go/triggers/... passes
  • SimulateEvent runs the handler against each of the six fixture files (Stripe, GitHub, Slack, generic_hmac, generic_bearer, cron) and produces the expected *triggers.Context shape
  • Fixture JSON files are byte-identical to the Python SDK's copies (verified by a small helper test)

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-friendlyWell-documented task suitable for AI-assisted developmentarea:sdkCross-SDK (Python + Go + TS) parity workenhancementNew feature or requesthelp wantedExtra attention is neededsdk:goGo SDK related

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions