diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-16 04:39:45 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-16 04:39:45 +0200 |
| commit | 122d078901d54828be6cfe0b592cbff077be6957 (patch) | |
| tree | 624c51df234f977ed1822a1fbb8b92baa417e2ad | |
| parent | 5e0cf1ede41b2887db98ca61c8100cbe1da61170 (diff) | |
Strengthen LLM stats counter tests with value assertions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| -rw-r--r-- | internal/lsp/llm_stats_test.go | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/internal/lsp/llm_stats_test.go b/internal/lsp/llm_stats_test.go index 7813c10..e2e9243 100644 --- a/internal/lsp/llm_stats_test.go +++ b/internal/lsp/llm_stats_test.go @@ -2,9 +2,39 @@ package lsp import "testing" -func TestLogLLMStats_CoversCounters(t *testing.T) { +func TestIncSentCounters(t *testing.T) { + s := newTestServer() + s.incSentCounters(10) + s.incSentCounters(20) + if got := s.llmReqTotal.Load(); got != 2 { + t.Fatalf("expected reqTotal=2, got %d", got) + } + if got := s.llmSentBytesTotal.Load(); got != 30 { + t.Fatalf("expected sentBytesTotal=30, got %d", got) + } +} + +func TestIncRecvCounters(t *testing.T) { + s := newTestServer() + s.incRecvCounters(15) + if got := s.llmRespTotal.Load(); got != 1 { + t.Fatalf("expected respTotal=1, got %d", got) + } + if got := s.llmRespBytesTotal.Load(); got != 15 { + t.Fatalf("expected respBytesTotal=15, got %d", got) + } +} + +func TestLogLLMStats_ZeroCounters(t *testing.T) { + s := newTestServer() + // Should not panic with zero counters (divide-by-zero guard). + s.logLLMStats("model") +} + +func TestLogLLMStats_WithData(t *testing.T) { s := newTestServer() s.incSentCounters(10) s.incRecvCounters(20) - s.logLLMStats("model") // just ensure it does not panic and executes + // Should not panic and exercises the averaging paths. + s.logLLMStats("model") } |
