fix task duration recording

This commit is contained in:
2026-05-18 01:06:52 +08:00
parent d09a4c2e4d
commit ba419cd90a
6 changed files with 44 additions and 6 deletions
@@ -110,6 +110,7 @@ func TestOpenAIClientChatContract(t *testing.T) {
t.Fatalf("decode request: %v", err)
}
gotModel, _ = body["model"].(string)
time.Sleep(25 * time.Millisecond)
_ = json.NewEncoder(w).Encode(map[string]any{
"id": "chatcmpl-test",
"object": "chat.completion",
@@ -145,6 +146,9 @@ func TestOpenAIClientChatContract(t *testing.T) {
if response.RequestID != "req-chat-test" || response.ResponseStartedAt.IsZero() || response.ResponseFinishedAt.IsZero() {
t.Fatalf("response metadata was not captured: %+v", response)
}
if response.ResponseDurationMS < 20 {
t.Fatalf("response duration should include upstream latency, got %dms", response.ResponseDurationMS)
}
}
func TestOpenAIClientChatStreamContract(t *testing.T) {