Skip to content

Commit 80994d6

Browse files
committed
MockRecorder Total*Tokens
1 parent 70fea88 commit 80994d6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

internal/testutil/mock_recorder.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,21 @@ func (m *MockRecorder) RecordedTokenUsages() []*recorder.TokenUsageRecord {
7676

7777
// TotalInputTokens returns the sum of input tokens across all recorded token usages.
7878
func (m *MockRecorder) TotalInputTokens() int64 {
79+
m.mu.Lock()
80+
defer m.mu.Unlock()
7981
var total int64
80-
for _, el := range m.RecordedTokenUsages() {
82+
for _, el := range m.tokenUsages {
8183
total += el.Input
8284
}
8385
return total
8486
}
8587

8688
// TotalOutputTokens returns the sum of output tokens across all recorded token usages.
8789
func (m *MockRecorder) TotalOutputTokens() int64 {
90+
m.mu.Lock()
91+
defer m.mu.Unlock()
8892
var total int64
89-
for _, el := range m.RecordedTokenUsages() {
93+
for _, el := range m.tokenUsages {
9094
total += el.Output
9195
}
9296
return total

0 commit comments

Comments
 (0)