v0.13.0 befd698

update_goal_test.go RawHistoryFolder

1package tools
2
3import (
4	"context"
5	"encoding/json"
6	"testing"
7
8	"github.com/bnema/zut/packages/core"
9)
10
11func TestUpdateGoalToolReturnsPersistableStatus(t *testing.T) {
12	tool := &UpdateGoalTool{}
13	raw, err := json.Marshal(map[string]string{"status": "complete"})
14	if err != nil {
15		t.Fatal(err)
16	}
17	result, err := tool.Execute(context.Background(), raw, nil)
18	if err != nil {
19		t.Fatal(err)
20	}
21	if result.IsError {
22		t.Fatalf("result = %#v, want success", result)
23	}
24	update, ok := GoalUpdateFromResult(result)
25	if !ok {
26		t.Fatalf("details = %#v, want goal update", result.Details)
27	}
28	if update.Status != core.GoalDone || update.Reason != "" {
29		t.Fatalf("update = %#v", update)
30	}
31}
32
33func TestUpdateGoalToolRejectsUnknownFields(t *testing.T) {
34	tool := &UpdateGoalTool{}
35	result, err := tool.Execute(context.Background(), json.RawMessage(`{"status":"complete","unexpected":true}`), nil)
36	if err != nil {
37		t.Fatal(err)
38	}
39	if !result.IsError {
40		t.Fatalf("result = %#v, want tool error", result)
41	}
42}
43
44func TestGoalUpdateFromResultRejectsBlockedWithoutReason(t *testing.T) {
45	result := core.ToolResult{Details: GoalUpdate{Status: core.GoalBlocked}}
46	if _, ok := GoalUpdateFromResult(result); ok {
47		t.Fatal("blank-reason blocked update was accepted")
48	}
49
50	result.Details = GoalUpdate{Status: core.GoalBlocked, Reason: "needs user input"}
51	if _, ok := GoalUpdateFromResult(result); !ok {
52		t.Fatal("blocked update with reason was rejected")
53	}
54
55	result.Details = GoalUpdate{Status: core.GoalDone}
56	if _, ok := GoalUpdateFromResult(result); !ok {
57		t.Fatal("completed update without reason was rejected")
58	}
59}
60
61func TestUpdateGoalToolRejectsUnsupportedStatus(t *testing.T) {
62	tool := &UpdateGoalTool{}
63	raw := json.RawMessage(`{"status":"active"}`)
64	result, err := tool.Execute(context.Background(), raw, nil)
65	if err != nil {
66		t.Fatal(err)
67	}
68	if !result.IsError {
69		t.Fatalf("result = %#v, want tool error", result)
70	}
71	if _, ok := GoalUpdateFromResult(result); ok {
72		t.Fatal("invalid result exposed a goal update")
73	}
74}

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 477

↑↓ moveenter openesc close