summaryrefslogtreecommitdiff
path: root/internal/lsp/llm_stats_test.go
blob: e2e92436830104783076a14ef8a4f7def54a00f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package lsp

import "testing"

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)
	// Should not panic and exercises the averaging paths.
	s.logLLMStats("model")
}