v0.3.58 532d7f6

discover_gondola_test.go RawHistoryFolder

1package provider
2
3import (
4	"context"
5	"fmt"
6	"net/http"
7	"net/http/httptest"
8	"testing"
9)
10
11func TestDiscoverGondolaMapsTextModels(t *testing.T) {
12	const body = `{"data":[
13		{"id":"kimi-k3","display_name":"Kimi K3","modality":"text","endpoint":"/v1/chat/completions",
14		 "context_length":1000000,"max_completion_tokens":131072,"supports_reasoning":true,
15		 "pricing":{"input_usd_per_mtok":1.1475,"output_usd_per_mtok":5.7375,"cached_input_usd_per_mtok":0.11475}},
16		{"id":"claude-opus-5","display_name":"Claude Opus 5","modality":"text","endpoint":"/v1/chat/completions",
17		 "context_length":1000000,"max_completion_tokens":128000,"supports_reasoning":true,
18		 "pricing":{"input_usd_per_mtok":1.836,"output_usd_per_mtok":9.18,"cached_input_usd_per_mtok":0.1836,"cache_write_usd_per_mtok":2.295}},
19		{"id":"image","display_name":"Image","modality":"image","endpoint":"/v1/images/generations"},
20		{"id":"wrong-endpoint","display_name":"Wrong endpoint","modality":"text","endpoint":"/v1/messages"},
21		{"id":"","display_name":"Missing ID","modality":"text","endpoint":"/v1/chat/completions"}
22	]}`
23	srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
24		if r.URL.Path != "/models" {
25			t.Fatalf("request path = %q", r.URL.Path)
26		}
27		w.Header().Set("content-type", "application/json")
28		fmt.Fprint(w, body)
29	}))
30	defer srv.Close()
31
32	models, err := DiscoverGondola(context.Background(), srv.URL+"/")
33	if err != nil {
34		t.Fatal(err)
35	}
36	if len(models) != 2 {
37		t.Fatalf("models = %+v", models)
38	}
39
40	kimi := models[0]
41	if kimi.Provider != "gondola" || kimi.ID != "kimi-k3" || kimi.DisplayName != "Kimi K3" ||
42		kimi.ContextWindow != 1000000 || kimi.MaxOutput != 131072 || !kimi.Reasoning || kimi.AdaptiveThinking ||
43		kimi.PriceInput != 1.1475 || kimi.PriceOutput != 5.7375 || kimi.PriceCacheRead != 0.11475 ||
44		kimi.BaseURL != srv.URL || kimi.Source != "live" {
45		t.Fatalf("kimi model = %+v", kimi)
46	}
47
48	opus := models[1]
49	if opus.ID != "claude-opus-5" || !opus.AdaptiveThinking || opus.PriceCacheRead != 0.1836 || opus.PriceCacheWrite != 2.295 {
50		t.Fatalf("opus model = %+v", opus)
51	}
52}
53
54func TestDiscoverGondolaReportsHTTPError(t *testing.T) {
55	srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
56		http.Error(w, "unavailable", http.StatusServiceUnavailable)
57	}))
58	defer srv.Close()
59
60	_, err := DiscoverGondola(context.Background(), srv.URL)
61	if err == nil {
62		t.Fatal("expected discovery error")
63	}
64}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close