bots-garden/mini-mepublic Fork 0
main
Commits
Clone
git clone https://git.rickub.com/bots-garden/mini-me.git
git clone ssh://git@rickub.com/bots-garden/mini-me.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

💾 Saved. d722711 · on main · k33g · 3h ago
ui_test.go · 54 lines · 1.8 KBGo Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package ui

import (
	"context"
	"strings"
	"testing"
)

// stubSink is the smallest Sink that can carry a working directory.
type stubSink struct{ cwd string }

func (stubSink) Text(string)                           {}
func (stubSink) ToolStart(ToolEvent)                   {}
func (stubSink) Allow(context.Context, ToolEvent) bool { return true }
func (stubSink) ToolRunning(string)                    {}
func (stubSink) ToolEnd(string, ToolResult)            {}
func (s stubSink) WorkDir() string                     { return s.cwd }

// With no sink — the terminal front end — Resolve must be the identity: part
// 10's behaviour, paths relative to the process, unchanged.
func TestResolveWithoutSinkIsIdentity(t *testing.T) {
	SetActive(nil)
	for _, p := range []string{"hello/main.go", "../x", "/abs/path"} {
		if got := Resolve(p); got != p {
			t.Errorf("Resolve(%q) = %q, want unchanged", p, got)
		}
	}
}

// With a sink, a relative path follows the SESSION's working directory — the
// project open in the editor — and an absolute one is left alone.
func TestResolveWithSinkFollowsTheSession(t *testing.T) {
	SetActive(stubSink{cwd: "/work/project"})
	defer SetActive(nil)

	if got := Resolve("hello/main.go"); got != "/work/project/hello/main.go" {
		t.Errorf("relative path: got %q", got)
	}
	if got := Resolve("/etc/hosts"); got != "/etc/hosts" {
		t.Errorf("absolute path must not move: got %q", got)
	}
}

// Call IDs must never repeat: an ACP client correlates tool_call and
// tool_call_update by them, and a duplicate would merge two calls in its UI.
func TestNextCallIDNeverRepeats(t *testing.T) {
	a, b := NextCallID(), NextCallID()
	if a == b {
		t.Fatalf("two calls, same id: %q", a)
	}
	if !strings.HasPrefix(a, "call_") {
		t.Fatalf("unexpected shape: %q", a)
	}
}