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

Function TestSubmitResetsFailureStreak

internal/tui/tui_test.go:1918–1931  ·  view source on GitHub ↗

TestSubmitResetsFailureStreak: a fresh user submission is a new goal, so a stale streak from the previous goal must not carry over and trip the nudge early. submit's non-slash path zeroes failKey/failStreak.

(t *testing.T)

Source from the content-addressed store, hash-verified

1916func TestRepeatedFailureNudgeDifferentTargetResetsStreak(t *testing.T) {
1917 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
1918 fail := chmctx.Message{Role: chmctx.RoleTool, ToolName: tools.BashName, Content: "x\n(exit: exit status 1)"}
1919
1920 var mm tea.Model = m
1921 // Each iteration fails, but against a different bash target, so the streak
1922 // keeps resetting to 1 and never reaches maxToolFailStreak.
1923 for i := 0; i < maxToolFailStreak+2; i++ {
1924 cur := mm.(Model)
1925 cur.lastToolKey = fmt.Sprintf("%s|echo %d", tools.BashName, i)
1926 out, _ := cur.recordAndNudge(fail)
1927 mm = out
1928 }
1929 final := mm.(Model)
1930 for _, msg := range final.history {
1931 if msg.Role == chmctx.RoleSystem {
1932 t.Fatalf("distinct targets must not trip the nudge, but one fired:\n%+v", final.history)
1933 }
1934 }

Callers

nothing calls this directly

Calls 2

newTestModelFunction · 0.85
submitMethod · 0.80

Tested by

no test coverage detected