diff options
| -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") } |
