bots-garden/mini-mepublic Fork 0
d72271127802973540c648bfb372176cdaaa8e4f
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.

files_test.go · 33 lines · 1.3 KBGo Blame HistoryRaw
💾 Saved. d722711 k33g 7h ago1package tools
2
3import (
4 "strings"
5 "testing"
6
7 "mm/internal/fileedit"
8)
9
10// TestClip: a display line is scanned, not read. A hundred columns, one line —
11// the same rule as the command recap, and the same reason: a multi-line old
12// text printed whole would be longer than the diff it announces.
13func TestClip(t *testing.T) {
14 if got := clip("📝 edit_file: a.go\n (2 edits)"); got != "📝 edit_file: a.go (2 edits)" {
15 t.Errorf("clip folded to %q", got)
16 }
17 long := clip("📄 read_file: " + strings.Repeat("x", 200))
18 if r := []rune(long); len(r) != maxDisplayWidth || r[len(r)-1] != '…' {
19 t.Errorf("clip = %d runes ending %q, want %d ending …", len(r), string(r[len(r)-1]), maxDisplayWidth)
20 }
21}
22
23// TestEditKeyTellsRetriesApart: the loop detector must see a corrected edit as
24// a NEW action. Keying on the path alone made "same path, different old text"
25// look like a repeat, and the detector fired on a model that was fixing itself.
26func TestEditKeyTellsRetriesApart(t *testing.T) {
27 a := editKey(editFileInput{Path: "f.go", Edits: []fileedit.Edit{{Old: "x", New: "y"}}})
28 b := editKey(editFileInput{Path: "f.go", Edits: []fileedit.Edit{{Old: "x2", New: "y"}}})
29 same := editKey(editFileInput{Path: "f.go", Edits: []fileedit.Edit{{Old: "x", New: "y"}}})
30 if a == b || a != same {
31 t.Errorf("editKey: a=%q b=%q same=%q", a, b, same)
32 }
33}