MCPcopy Create free account
hub / github.com/InferCore/InferCore / TestReplayExact_InferenceSuccess

Function TestReplayExact_InferenceSuccess

internal/replay/replay_test.go:94–150  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

92}
93
94func TestReplayExact_InferenceSuccess(t *testing.T) {
95 cfg := replayTestConfig()
96 st := requests.NewMemoryStore()
97 req := types.AIRequest{
98 RequestType: types.RequestTypeInference,
99 TenantID: "team-a",
100 TaskType: "chat",
101 Priority: "high",
102 Input: map[string]any{"text": "exact replay"},
103 Options: types.RequestOptions{Stream: false, MaxTokens: 64},
104 }
105 full, _ := json.Marshal(req)
106 snap := types.PolicySnapshot{
107 PrimaryBackend: "small-model",
108 PrimaryRouteReason: "test",
109 EstimatedCost: 1,
110 }
111 snapBytes, _ := json.Marshal(snap)
112 now := time.Now()
113 _ = st.CreateRequest(context.Background(), requests.RequestRow{
114 RequestID: "rid-exact-ok",
115 TraceID: "trace-1",
116 TenantID: req.TenantID,
117 TaskType: req.TaskType,
118 Priority: req.Priority,
119 RequestType: types.RequestTypeInference,
120 PipelineRef: types.DefaultPipelineInference,
121 AIRequestJSON: full,
122 PolicySnapshot: snapBytes,
123 SelectedBackend: "small-model",
124 CreatedAt: now,
125 UpdatedAt: now,
126 })
127 ad := mock.New(cfg.Backends[0])
128 deps := NewDependenciesFromConfig(cfg, map[string]interfaces.BackendAdapter{
129 "small-model": ad,
130 }, nil)
131 resp, err := Replay(context.Background(), cfg, st, "rid-exact-ok", ModeExact, deps)
132 if err != nil {
133 t.Fatalf("replay: %v", err)
134 }
135 if resp.Status != "success" {
136 t.Fatalf("status=%q", resp.Status)
137 }
138 if resp.RouteReason != "replay_exact" {
139 t.Fatalf("route_reason=%q", resp.RouteReason)
140 }
141 if resp.PolicyReason != "replay_exact" {
142 t.Fatalf("policy_reason=%q", resp.PolicyReason)
143 }
144 if resp.SelectedBackend != "small-model" {
145 t.Fatalf("backend=%q", resp.SelectedBackend)
146 }
147 if resp.TraceID != "trace-1" {
148 t.Fatalf("trace_id=%q", resp.TraceID)
149 }
150}
151

Callers

nothing calls this directly

Calls 6

NewMemoryStoreFunction · 0.92
NewFunction · 0.92
replayTestConfigFunction · 0.85
ReplayFunction · 0.85
CreateRequestMethod · 0.65

Tested by

no test coverage detected