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

Function TestRunSlashWarnsOnBrokenConfig

internal/tui/tui_test.go:974–996  ·  view source on GitHub ↗

TestRunSlashWarnsOnBrokenConfig: a typo in config.yaml must not lock the user out of slash commands. The reload prints a one-line warning and keeps the previous in-memory cfg, so /models (and further editing) keep working with last-known-good state.

(t *testing.T)

Source from the content-addressed store, hash-verified

972 t.Fatalf("tool result missing: %+v", final.history[2])
973 }
974 if !strings.Contains(stripANSI(final.scroll.String()), "echoed HAMMER for you") {
975 t.Fatalf("final assistant content missing from scroll: %q", final.scroll.String())
976 }
977 // No tool calls → idle, control back to the user.
978 if final.phase.active() {
979 t.Fatalf("turn ending with no tool calls must return to idle, phase=%v", final.phase)
980 }
981 // The frozen run summary must sum tokens across both LLM rounds, not
982 // overwrite. Round 1 reports usage.completion_tokens=5, round 2 reports 1.
983 // finalizeTurn freezes turnTokens into lastTokens (the avg rate divisor). Sum = 6.
984 if final.lastTokens != 6 {
985 t.Fatalf("per-turn tokens should sum across rounds (5+1), got %d", final.lastTokens)
986 }
987 // A clean finish (no tool calls) freezes the ✓ outcome for the idle footer.
988 if final.lastOutcome != outcomeDone {
989 t.Fatalf("clean finish should freeze outcomeDone, got %v", final.lastOutcome)
990 }
991}
992
993// TestToolArgsStreamBumpsEstimateAndPhase: a tool call argument fragment (a file
994// streaming into write_file) ticks the live token estimate AND flips the phase
995// to "generating", so the counter doesn't freeze through a long file write: the
996// bug where only chat content and reasoning were counted, not tool arguments.
997func TestToolArgsStreamBumpsEstimateAndPhase(t *testing.T) {
998 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
999 m.phase = phaseThinking // a tool only round starts here, before any content

Callers

nothing calls this directly

Calls 4

newTestModelFunction · 0.85
stripANSIFunction · 0.85
runSlashMethod · 0.80
StringMethod · 0.80

Tested by

no test coverage detected