MCPcopy Create free account
hub / github.com/github/gh-aw / TestCacheEfficiency

Function TestCacheEfficiency

pkg/cli/token_usage_test.go:703–715  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

701}
702
703func TestCacheEfficiency(t *testing.T) {
704 t.Run("remains zero to avoid transforming raw token counts", func(t *testing.T) {
705 tmpDir := testutil.TempDir(t, "cache-eff")
706 filePath := filepath.Join(tmpDir, "token-usage.jsonl")
707 content := `{"provider":"anthropic","model":"sonnet","input_tokens":100,"output_tokens":50,"cache_read_tokens":9900,"cache_write_tokens":0,"duration_ms":100}`
708 require.NoError(t, os.WriteFile(filePath, []byte(content+"\n"), 0o644))
709
710 summary, err := parseTokenUsageFile(filePath)
711 require.NoError(t, err)
712 require.NotNil(t, summary)
713 assert.InDelta(t, 0.0, summary.CacheEfficiency, 0.001, "cache efficiency should remain unset")
714 })
715}
716
717func TestModelTokenUsageReasoningTokensJSONRoundTrip(t *testing.T) {
718 original := ModelTokenUsage{

Callers

nothing calls this directly

Calls 3

TempDirFunction · 0.92
parseTokenUsageFileFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected