summaryrefslogtreecommitdiff
path: root/internal/llm
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-09-04 16:29:57 +0300
committerPaul Buetow <paul@buetow.org>2025-09-04 16:29:57 +0300
commitd99bdf981dbee7e038e4a8e262504c1a15047c38 (patch)
treeeb866c854c2c8b10bbacf53e38fdd9c7fe66d66f /internal/llm
parent2a6ff853c20e6c1c780c69affdadacda2db202b6 (diff)
tests: add more table-driven cases and negative provider tests; update report
Diffstat (limited to 'internal/llm')
-rw-r--r--internal/llm/copilot_http_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/llm/copilot_http_test.go b/internal/llm/copilot_http_test.go
index 30144d1..2e46d68 100644
--- a/internal/llm/copilot_http_test.go
+++ b/internal/llm/copilot_http_test.go
@@ -108,6 +108,25 @@ func TestCopilot_Chat_MultiChoice_And_ErrorBody(t *testing.T) {
}
}
+func TestCopilot_Chat_DecodeError_StatusOK(t *testing.T) {
+ // Chat returns 200 but invalid JSON; expect decode error
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ io.WriteString(w, "{invalid")
+ }))
+ defer srv.Close()
+ c := newCopilot(srv.URL, "gpt-4o-mini", "KEY", f64p(0.1)).(copilotClient)
+ tr := rtFunc2(func(r *http.Request) (*http.Response, error) {
+ if r.URL.Host == "api.github.com" && r.URL.Path == "/copilot_internal/v2/token" {
+ rw := httptest.NewRecorder(); _ = json.NewEncoder(rw).Encode(map[string]string{"token":"tok"}); res := rw.Result(); res.StatusCode = 200; return res, nil
+ }
+ return http.DefaultTransport.RoundTrip(r)
+ })
+ c.httpClient = &http.Client{Transport: tr, Timeout: 5 * time.Second}
+ if _, err := c.Chat(context.Background(), []Message{{Role:"user", Content:"hi"}}); err == nil {
+ t.Fatalf("expected decode error for invalid body")
+ }
+}
+
func TestCopilot_CodeCompletion_MalformedAndEmpty(t *testing.T) {
c := newCopilot("https://api.githubcopilot.com", "gpt-4o-mini", "API", f64p(0.1)).(copilotClient)
tr := rtFunc2(func(r *http.Request) (*http.Response, error) {