(t *testing.T)
| 446 | } |
| 447 | |
| 448 | func TestSessionFromEventsTokenUsage(t *testing.T) { |
| 449 | t.Parallel() |
| 450 | |
| 451 | events := []map[string]any{ |
| 452 | {"type": "agent_choice", "content": "Answer"}, |
| 453 | { |
| 454 | "type": "token_usage", |
| 455 | "usage": map[string]any{ |
| 456 | "input_tokens": float64(100), |
| 457 | "output_tokens": float64(50), |
| 458 | "cost": 0.005, |
| 459 | }, |
| 460 | }, |
| 461 | {"type": "stream_stopped"}, |
| 462 | } |
| 463 | |
| 464 | sess := SessionFromEvents(events, "test", []string{"question"}) |
| 465 | |
| 466 | assert.Equal(t, int64(100), sess.InputTokens) |
| 467 | assert.Equal(t, int64(50), sess.OutputTokens) |
| 468 | assert.InDelta(t, 0.005, sess.Cost, 0.0001) |
| 469 | } |
| 470 | |
| 471 | func TestParseToolCall(t *testing.T) { |
| 472 | t.Parallel() |
nothing calls this directly
no test coverage detected