MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestToolTargetKey

Function TestToolTargetKey

internal/tui/tui_test.go:1727–1757  ·  view source on GitHub ↗

TestToolTargetKey pins the identity the repeated-failure nudge keys on: file tools key on tool+path, bash on tool + the trimmed first command line, else the bare tool name. Deliberately NOT the full args: a cosmetic retry change (regenerated body, reworded tail) must not reset the streak.

(t *testing.T)

Source from the content-addressed store, hash-verified

1725// in streamingEstimate. finalizeTurn must commit that estimate so the frozen avg
1726// counts what was generated up to the interrupt and the session total doesn't
1727// drop backward. (On a clean finish the estimate is already 0, so this is a no-op.)
1728func TestFinalizeFoldsInFlightEstimate(t *testing.T) {
1729 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
1730 m.turnStart = time.Now()
1731 m.turnTokens = 40 // one completed round
1732 m.streamingEstimate = 60 // an in-flight round cancelled before EventDone
1733 m.sessionTokens = 200
1734 m.finalizeTurn(outcomeStopped)
1735 if m.lastTokens != 100 {
1736 t.Fatalf("frozen tokens should fold the in-flight estimate (40+60), got %d", m.lastTokens)
1737 }
1738 if m.sessionTokens != 260 {
1739 t.Fatalf("session total should absorb the in-flight estimate (200+60), got %d", m.sessionTokens)
1740 }
1741 if m.streamingEstimate != 0 {
1742 t.Fatalf("finalizeTurn should consume the estimate, got %d", m.streamingEstimate)
1743 }
1744 if m.lastOutcome != outcomeStopped {
1745 t.Fatalf("abort should freeze outcomeStopped, got %v", m.lastOutcome)
1746 }
1747}
1748
1749// TestToolTargetKey pins the identity the repeated-failure nudge keys on: file
1750// tools key on tool+path, bash on tool + the trimmed first command line, else
1751// the bare tool name. Deliberately NOT the full args: a cosmetic retry change
1752// (regenerated body, reworded tail) must not reset the streak.
1753func TestToolTargetKey(t *testing.T) {
1754 cases := []struct {
1755 name string
1756 call chmctx.ToolCall
1757 want string
1758 }{
1759 {"write_file keys on path", chmctx.ToolCall{
1760 Name: tools.WriteFileName, Arguments: map[string]any{"path": "/a/b.go", "content": "anything"},

Callers

nothing calls this directly

Calls 1

toolTargetKeyFunction · 0.85

Tested by

no test coverage detected