From 122d078901d54828be6cfe0b592cbff077be6957 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 16 Mar 2026 04:39:45 +0200 Subject: Strengthen LLM stats counter tests with value assertions Co-Authored-By: Claude Opus 4.6 --- internal/lsp/llm_stats_test.go | 34 ++++++++++++++++++++++++++++++++-- 1 file 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") } -- cgit v1.2.3