MCPcopy Index your code
hub / github.com/docker/docker-agent / TestSessionFromEventsTokenUsage

Function TestSessionFromEventsTokenUsage

pkg/evaluation/save_test.go:448–469  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

446}
447
448func 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
471func TestParseToolCall(t *testing.T) {
472 t.Parallel()

Callers

nothing calls this directly

Calls 1

SessionFromEventsFunction · 0.85

Tested by

no test coverage detected