package audit

import "context"

// TestingTB is the minimal subset of *testing.T needed by
// AssertEntrypointInContext. Declared as an interface so the helper is
// usable from any test (in this or a downstream package) without pulling
// the full testing.TB surface through.
//
// NOTE: this file lives outside _test.go so AssertEntrypointInContext is
// reachable from integration tests in other packages (e.g.
// internal/features/automation). The helper is pure and has no runtime
// cost in the shipping binary beyond a function declaration.
type TestingTB interface {
	Helper()
	Fatalf(format string, args ...interface{})
}

// AssertEntrypointInContext is a test helper for integration tests that
// need to verify upstream executor wiring set the expected Entrypoint on
// ctx (design §3.5). On mismatch, fails the test with a clear message.
//
// Example:
//
//	audit.AssertEntrypointInContext(t, capturedCtx, audit.EntrypointFlow)
func AssertEntrypointInContext(t TestingTB, ctx context.Context, expected AuditEntrypoint) {
	t.Helper()
	got := EntrypointFromContext(ctx)
	if got != expected {
		t.Fatalf("audit.Entrypoint on ctx: got %q, want %q", got, expected)
	}
}
