runModelHook is a small helper that builds a Handler via NewModelFactory and dispatches once. It returns the handler result plus any factory/run error so tests can assert on either path.
(t *testing.T, client ModelClient, h Hook, in *Input)
| 38 | // NewModelFactory and dispatches once. It returns the handler result |
| 39 | // plus any factory/run error so tests can assert on either path. |
| 40 | func runModelHook(t *testing.T, client ModelClient, h Hook, in *Input) (HandlerResult, error) { |
| 41 | t.Helper() |
| 42 | factory := NewModelFactory(client) |
| 43 | handler, err := factory(HandlerEnv{}, h) |
| 44 | if err != nil { |
| 45 | return HandlerResult{}, err |
| 46 | } |
| 47 | body, err := in.ToJSON() |
| 48 | require.NoError(t, err) |
| 49 | return handler.Run(t.Context(), body) |
| 50 | } |
| 51 | |
| 52 | // TestNewModelFactoryRejectsMissingFields documents the up-front |
| 53 | // validation: a Hook lacking Model or Prompt must fail at factory |
no test coverage detected