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

Function TestHamrpassLazyCreatesProfile

internal/tui/tui_test.go:2991–3021  ·  view source on GitHub ↗

TestHamrpassLazyCreatesProfile: a user who hid hamrpass from config.yaml can still activate it by pasting a key. /hamrpass creates the profile from canonical seed values, stores the key, and flips active.

(t *testing.T)

Source from the content-addressed store, hash-verified

2989 if attempts == 1 {
2990 w.WriteHeader(http.StatusNotFound)
2991 fmt.Fprint(w, `{"detail":"Not Found"}`)
2992 return
2993 }
2994 w.Header().Set("Content-Type", "text/event-stream")
2995 fmt.Fprintf(w, "data: %s\n\n", `{"type":"response.output_text.delta","delta":"recovered"}`)
2996 fmt.Fprint(w, "data: {\"type\":\"response.completed\",\"response\":{}}\n\n")
2997 })
2998 m.cli.RetryBackoff = []time.Duration{time.Millisecond, time.Millisecond, time.Millisecond}
2999
3000 mm, cmd := m.submit("ping", "ping", promptEntry{display: "ping"})
3001 out, _ := drain(mm, cmd)
3002 final := out.(Model)
3003
3004 if attempts != 2 {
3005 t.Fatalf("attempts = %d, want 2 (one 404, one success)", attempts)
3006 }
3007 scroll := stripANSI(final.scroll.String())
3008 if !strings.Contains(scroll, "recovered") {
3009 t.Fatalf("assistant content missing after retry: %q", scroll)
3010 }
3011 if strings.Contains(scroll, "404") {
3012 t.Fatalf("a recovered turn must not surface the 404 to the user: %q", scroll)
3013 }
3014 if final.status != "" {
3015 t.Fatalf("retry hint must be cleared after recovery, got %q", final.status)
3016 }
3017 if final.phase.active() {
3018 t.Fatalf("turn must end idle, phase=%v", final.phase)
3019 }
3020}
3021
3022// TestToolSchemasFitFixedToolsReservation is the FixedSystem pin's missing
3023// sibling. The four schemas ride on every request exactly like the prompt does,
3024// and they grow the same way (read_file gained offset/limit, write_file gained

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
SaveMethod · 0.80
runSlashMethod · 0.80

Tested by

no test coverage detected