v0.3.67 80dd4c6

powershell_test.go RawHistoryFolder

1package agent
2
3import (
4	"testing"
5
6	"github.com/patriceckhart/zot/packages/agent/tools"
7)
8
9func TestPowerShellConfigToolSelection(t *testing.T) {
10	enabled, disabled := true, false
11	for _, tc := range []struct {
12		name, goos string
13		preference *bool
14		args       Args
15		want       bool
16	}{
17		{"default", "windows", nil, Args{}, false},
18		{"enabled", "windows", &enabled, Args{}, true},
19		{"disabled", "windows", &disabled, Args{}, false},
20		{"other OS", "darwin", &enabled, Args{}, false},
21		{"no tools", "windows", &enabled, Args{NoTools: true}, false},
22		{"explicit exclusion", "windows", &enabled, Args{Tools: []string{"read"}}, false},
23		{"explicit inclusion", "windows", &disabled, Args{Tools: []string{"powershell"}}, true},
24	} {
25		t.Run(tc.name, func(t *testing.T) {
26			reg := buildConfiguredToolRegistry(tc.args, t.TempDir(), nil, Config{PowerShellEnabled: tc.preference}, tc.goos)
27			if (reg["powershell"] != nil) != tc.want {
28				t.Fatalf("registry: %v", reg)
29			}
30			if tc.name == "enabled" && reg["bash"] == nil {
31				t.Fatal("setting removed bash")
32			}
33		})
34	}
35}
36
37func TestPowerShellSettingPersistence(t *testing.T) {
38	t.Setenv("ZOT_HOME", t.TempDir())
39	if err := SaveConfig(Config{Theme: "dark"}); err != nil {
40		t.Fatal(err)
41	}
42	for _, enabled := range []bool{true, false} {
43		if err := (configSettingsStore{}).SetPowerShell(enabled); err != nil {
44			t.Fatal(err)
45		}
46		cfg, err := LoadConfig()
47		if err != nil {
48			t.Fatal(err)
49		}
50		if cfg.PowerShellEnabled == nil || *cfg.PowerShellEnabled != enabled || cfg.Theme != "dark" {
51			t.Fatalf("config not preserved: %+v", cfg)
52		}
53		reg := buildConfiguredToolRegistry(Args{}, t.TempDir(), nil, cfg, "windows")
54		if (reg["powershell"] != nil) != enabled {
55			t.Fatal("saved preference not applied")
56		}
57	}
58}
59
60func TestPowerShellToolSelection(t *testing.T) {
61	cwd := t.TempDir()
62	sb := tools.NewSandbox(cwd)
63	if _, ok := buildToolRegistry(Args{}, cwd, sb)["powershell"]; ok {
64		t.Fatal("PowerShell enabled by default")
65	}
66	args, err := ParseArgs([]string{"--tools", "read,powershell,glob"})
67	if err != nil {
68		t.Fatal(err)
69	}
70	reg := buildToolRegistry(args, cwd, sb)
71	ps, ok := reg["powershell"].(*tools.PowerShellTool)
72	if !ok || ps.CWD != cwd || ps.Sandbox != sb {
73		t.Fatalf("tool: %#v", reg["powershell"])
74	}
75	if len(reg) != 3 || reg["bash"] != nil {
76		t.Fatalf("registry: %v", reg)
77	}
78	found := false
79	for _, summary := range toolSummaries(reg, args) {
80		if summary.Name == "powershell" {
81			found = true
82		}
83	}
84	if !found {
85		t.Fatal("PowerShell missing from prompt summaries")
86	}
87	replacement := tools.NewSandbox(cwd)
88	r := &Resolved{ToolRegistry: reg, Sandbox: sb}
89	r.UseSandbox(replacement)
90	if ps.Sandbox != replacement {
91		t.Fatal("sandbox not replaced")
92	}
93	if len(buildToolRegistry(Args{NoTools: true, Tools: []string{"powershell"}}, cwd, sb)) != 0 {
94		t.Fatal("--no-tools ignored")
95	}
96	both := buildToolRegistry(Args{Tools: []string{"bash", "powershell"}}, cwd, sb)
97	if both["bash"] == nil || both["powershell"] == nil {
98		t.Fatal("cannot select both shells")
99	}
100}

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