v0.2.14 63e33d9

google_vertex_test.go RawHistoryFolder

1package provider
2
3import (
4	"os"
5	"path/filepath"
6	"testing"
7)
8
9func TestVertexConfigParsesAuthorizedUser(t *testing.T) {
10	// Write a fake ADC user-OAuth file and point GOOGLE_APPLICATION_CREDENTIALS at it.
11	tmp := t.TempDir()
12	path := filepath.Join(tmp, "adc.json")
13	body := `{
14	  "type": "authorized_user",
15	  "client_id": "fake.apps.googleusercontent.com",
16	  "client_secret": "fake-secret",
17	  "refresh_token": "1//fake-refresh"
18	}`
19	if err := os.WriteFile(path, []byte(body), 0o600); err != nil {
20		t.Fatal(err)
21	}
22	t.Setenv("GOOGLE_APPLICATION_CREDENTIALS", path)
23	t.Setenv("GOOGLE_CLOUD_PROJECT", "test-proj")
24	t.Setenv("GOOGLE_CLOUD_API_KEY", "") // ensure SA / user path is chosen
25	cfg, err := loadVertexConfig()
26	if err != nil {
27		t.Fatalf("loadVertexConfig: %v", err)
28	}
29	if cfg.userClientID != "fake.apps.googleusercontent.com" {
30		t.Errorf("client_id = %q", cfg.userClientID)
31	}
32	if cfg.userRefreshToken != "1//fake-refresh" {
33		t.Errorf("refresh_token = %q", cfg.userRefreshToken)
34	}
35	if cfg.userTokenURI != "https://oauth2.googleapis.com/token" {
36		t.Errorf("token_uri default not applied: %q", cfg.userTokenURI)
37	}
38	if cfg.cacheKey() != "user:fake.apps.googleusercontent.com" {
39		t.Errorf("cacheKey = %q", cfg.cacheKey())
40	}
41}
42
43func TestVertexConfigRejectsBadType(t *testing.T) {
44	tmp := t.TempDir()
45	path := filepath.Join(tmp, "adc.json")
46	body := `{"type": "something_else"}`
47	if err := os.WriteFile(path, []byte(body), 0o600); err != nil {
48		t.Fatal(err)
49	}
50	t.Setenv("GOOGLE_APPLICATION_CREDENTIALS", path)
51	t.Setenv("GOOGLE_CLOUD_PROJECT", "test-proj")
52	t.Setenv("GOOGLE_CLOUD_API_KEY", "")
53	_, err := loadVertexConfig()
54	if err == nil {
55		t.Fatal("expected error for unknown credential type")
56	}
57}

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