返回 DeepSeek-Reasonix
controller_stub_test.go
根目录 / internal / bot / controller_stub_test.go
1 package bot
2
3 import (
4 "context"
5
6 "reasonix/internal/agent"
7 "reasonix/internal/control"
8 "reasonix/internal/event"
9 "reasonix/internal/provider"
10 "reasonix/internal/sandbox"
11 )
12
13 // stubBotController implements the complete controller port with inert
14 // behavior. Bot test doubles embed this value and override only the behavior
15 // under test. Keeping an embedded nil interface here is unsafe: a promoted
16 // method call becomes a real nil-pointer hardware exception, and recover does
17 // not make that exception harmless on every Windows runner.
18 type stubBotController struct{}
19
20 func (stubBotController) NewSession() error { return nil }
21 func (stubBotController) ClearSession() error { return nil }
22 func (stubBotController) Resume(*agent.Session, string) {}
23 func (stubBotController) SetSessionPath(string) {}
24 func (stubBotController) SessionPath() string { return "" }
25 func (stubBotController) SessionDir() string { return "" }
26 func (stubBotController) Label() string { return "" }
27 func (stubBotController) ModelRef() string { return "" }
28 func (stubBotController) WorkspaceRoot() string { return "" }
29 func (stubBotController) Close() {}
30 func (stubBotController) Submit(string) {}
31 func (stubBotController) SubmitDisplay(string, string) {}
32 func (stubBotController) SubmitFinalReadinessRecovery(string, string) {}
33 func (stubBotController) SubmitDeliveryRecovery(string, string) {}
34 func (stubBotController) SubmitInvocationDisplay(string, string, []control.InvocationRequest) {
35 }
36 func (stubBotController) SubmitEditedDisplay(string, string, string) {}
37 func (stubBotController) SubmitHTTP(string) {}
38 func (stubBotController) SubmitHTTPFormat(string, string) {}
39 func (stubBotController) SubmitUserTurn(string, string) {}
40 func (stubBotController) Send(string) {}
41 func (stubBotController) SendWithRaw(string, string) {}
42 func (stubBotController) Run(context.Context, string) error { return nil }
43 func (stubBotController) RunTurn(context.Context, string) error { return nil }
44 func (stubBotController) RunFinalReadinessRecovery(context.Context, string) error { return nil }
45 func (stubBotController) RunShell(string) {}
46 func (stubBotController) Cancel() {}
47 func (stubBotController) Steer(string) {}
48 func (stubBotController) SteerConsumed() bool { return false }
49 func (stubBotController) Running() bool { return false }
50 func (stubBotController) CancelRequested() bool { return false }
51
52 // Pre-seeded fake sessions represent the currently executing test turn. Mark
53 // them running so unrelated config defaults cannot retire the fake before the
54 // test drives it; tests for idle replacement override RuntimeStatus directly.
55 func (stubBotController) RuntimeStatus() control.RuntimeStatus {
56 return control.RuntimeStatus{Running: true}
57 }
58 func (stubBotController) Turn() int { return 0 }
59 func (stubBotController) History() []provider.Message { return nil }
60 func (stubBotController) ToolResult(string) *control.ToolResultData { return nil }
61 func (stubBotController) Approve(string, bool, bool, bool) {}
62 func (stubBotController) ResolveApproval(string, bool, sandbox.ApprovalScope) error { return nil }
63 func (stubBotController) ResolvePlanDecision(string, control.PlanDecisionAction) error {
64 return nil
65 }
66 func (stubBotController) ResolvePlanDecisionWithFeedback(string, control.PlanDecisionAction, string) error {
67 return nil
68 }
69 func (stubBotController) ResolveRecovery(string, agent.RecoveryAction, string) error { return nil }
70 func (stubBotController) AnswerMCPInteraction(string, string, map[string]any) {}
71 func (stubBotController) AnswerQuestion(string, []event.AskAnswer) {}
72 func (stubBotController) AnswerQuestionChecked(string, []event.AskAnswer) error { return nil }
73 func (stubBotController) AnswerMCPInteractionChecked(string, string, map[string]any) error {
74 return nil
75 }
76 func (stubBotController) Ask(context.Context, []event.AskQuestion) ([]event.AskAnswer, error) {
77 return nil, nil
78 }
79 func (stubBotController) ReplayPendingPrompts() {}
80 func (stubBotController) ReplayPendingPromptsTo(event.Sink) {}
81 func (stubBotController) ReplayPendingPromptsWith(func() event.Sink) {}
82 func (stubBotController) PendingPrompt() bool { return false }
83 func (stubBotController) EnableInteractiveApproval() {}
84 func (stubBotController) ToolApprovalMode() string { return "" }
85 func (stubBotController) SetToolApprovalMode(string) {}
86 func (stubBotController) AutoApproveTools() bool { return false }
87 func (stubBotController) SetAutoApproveTools(bool) {}
88 func (stubBotController) Bypass() bool { return false }
89 func (stubBotController) SetBypass(bool) {}
90 func (stubBotController) SetMode(bool, bool) {}
91
92 var _ botController = stubBotController{}
93
93 lines GO