返回 DeepSeek-Reasonix
retry_indicator_test.go
根目录 / internal / cli / retry_indicator_test.go
1 package cli
2
3 import (
4 "fmt"
5 "strings"
6 "testing"
7
8 "reasonix/internal/event"
9 "reasonix/internal/i18n"
10 )
11
12 // TestRetryIndicatorShowsAndClears proves a Retrying event sets the transient
13 // retry fields the composer renders from, and that the next stream event clears
14 // them back to the normal thinking line.
15 func TestRetryIndicatorShowsAndClears(t *testing.T) {
16 m := newTestChatTUI()
17 m.state = tuiRunning
18
19 m.ingestEvent(event.Event{Kind: event.Retrying, RetryAttempt: 3, RetryMax: 10})
20 if m.retryAttempt != 3 || m.retryMax != 10 {
21 t.Fatalf("retry fields = %d/%d, want 3/10", m.retryAttempt, m.retryMax)
22 }
23
24 m.ingestEvent(event.Event{Kind: event.Text, Text: "answer"})
25 if m.retryAttempt != 0 || m.retryMax != 0 {
26 t.Fatalf("a stream event should clear the retry indicator, got %d/%d", m.retryAttempt, m.retryMax)
27 }
28 }
29
30 // TestRetryIndicatorText guards the composer's retry line wording — the same
31 // format string View() renders when retryAttempt > 0.
32 func TestRetryIndicatorText(t *testing.T) {
33 line := fmt.Sprintf(i18n.English.ChatStatusRetryingFmt, "⠋", 3, 10)
34 if !strings.Contains(line, "retrying (3/10)") {
35 t.Errorf("EN retry line = %q, want it to contain 'retrying (3/10)'", line)
36 }
37 zh := fmt.Sprintf(i18n.Chinese.ChatStatusRetryingFmt, "⠋", 3, 10)
38 if !strings.Contains(zh, "正在重试 (3/10)") {
39 t.Errorf("ZH retry line = %q, want it to contain '正在重试 (3/10)'", zh)
40 }
41 }
42
42 lines GO