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
files_test.go · 33 lines · 1.3 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
package tools

import (
	"strings"
	"testing"

	"mm/internal/fileedit"
)

// TestClip: a display line is scanned, not read. A hundred columns, one line —
// the same rule as the command recap, and the same reason: a multi-line old
// text printed whole would be longer than the diff it announces.
func TestClip(t *testing.T) {
	if got := clip("📝 edit_file: a.go\n  (2 edits)"); got != "📝 edit_file: a.go (2 edits)" {
		t.Errorf("clip folded to %q", got)
	}
	long := clip("📄 read_file: " + strings.Repeat("x", 200))
	if r := []rune(long); len(r) != maxDisplayWidth || r[len(r)-1] != '…' {
		t.Errorf("clip = %d runes ending %q, want %d ending …", len(r), string(r[len(r)-1]), maxDisplayWidth)
	}
}

// TestEditKeyTellsRetriesApart: the loop detector must see a corrected edit as
// a NEW action. Keying on the path alone made "same path, different old text"
// look like a repeat, and the detector fired on a model that was fixing itself.
func TestEditKeyTellsRetriesApart(t *testing.T) {
	a := editKey(editFileInput{Path: "f.go", Edits: []fileedit.Edit{{Old: "x", New: "y"}}})
	b := editKey(editFileInput{Path: "f.go", Edits: []fileedit.Edit{{Old: "x2", New: "y"}}})
	same := editKey(editFileInput{Path: "f.go", Edits: []fileedit.Edit{{Old: "x", New: "y"}}})
	if a == b || a != same {
		t.Errorf("editKey: a=%q b=%q same=%q", a, b, same)
	}
}