v0.15.0 6b178f8

discover_test.go RawHistoryFolder

1package provider
2
3import (
4	"context"
5	"io"
6	"net/http"
7	"net/http/httptest"
8	"testing"
9)
10
11func TestDiscoverOpenAICodex(t *testing.T) {
12	srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
13		if r.URL.Path != "/models" {
14			t.Errorf("path = %q, want /models", r.URL.Path)
15		}
16		if got := r.URL.Query().Get("client_version"); got != openaiCodexClientVersion {
17			t.Errorf("client_version = %q, want %q", got, openaiCodexClientVersion)
18		}
19		if got := r.Header.Get("authorization"); got != "Bearer token" {
20			t.Errorf("authorization = %q", got)
21		}
22		if got := r.Header.Get("chatgpt-account-id"); got != "account" {
23			t.Errorf("chatgpt-account-id = %q", got)
24		}
25		if got := r.Header.Get("originator"); got != "codex_cli_rs" {
26			t.Errorf("originator = %q", got)
27		}
28		_, _ = io.WriteString(w, `{"models":[
29			{"slug":"gpt-5.6-luna","display_name":"GPT-5.6 Luna","supported_in_api":true,"context_window":272000,"max_context_window":400000,"supported_reasoning_levels":["low","medium","high"]},
30			{"slug":"gpt-hidden","display_name":"Hidden","supported_in_api":true,"visibility":"hide"},
31			{"slug":"gpt-unsupported","display_name":"Unsupported","supported_in_api":false},
32			{"slug":"gpt-custom","supported_in_api":true,"max_context_window":100000}
33		]}`)
34	}))
35	defer srv.Close()
36
37	got, err := DiscoverOpenAICodex(context.Background(), "token", "account", srv.URL)
38	if err != nil {
39		t.Fatal(err)
40	}
41	if len(got) != 2 {
42		t.Fatalf("models = %+v, want 2 models", got)
43	}
44	if got[0].Provider != "openai-codex" || got[0].ID != "gpt-5.6-luna" || got[0].DisplayName != "GPT-5.6 Luna" || got[0].ContextWindow != 272000 || !got[0].Reasoning || got[0].Source != "live" {
45		t.Errorf("first model = %+v", got[0])
46	}
47	if got[1].ID != "gpt-custom" || got[1].DisplayName != "gpt-custom" || got[1].ContextWindow != 100000 {
48		t.Errorf("second model = %+v", got[1])
49	}
50}
51
52func TestDiscoverOpenAICodexRejectsHTTPError(t *testing.T) {
53	srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
54		http.Error(w, "denied", http.StatusUnauthorized)
55	}))
56	defer srv.Close()
57
58	if _, err := DiscoverOpenAICodex(context.Background(), "token", "", srv.URL); err == nil {
59		t.Fatal("DiscoverOpenAICodex error = nil, want HTTP error")
60	}
61}

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