Migrate HTTP and process fixtures without changing wire formats
This commit is contained in:
@@ -66,7 +66,7 @@ func TestHandlerExecutionReportOptInAndResultShapes(t *testing.T) {
|
||||
if req.Observer != nil {
|
||||
req.Observer(promptkit.ExecutionEvent{Kind: promptkit.ExecutionFinished, RunID: "observed", Outcome: outcome, Failure: promptkit.ExecutionFailureNone, Attempts: 2})
|
||||
}
|
||||
return &promptkit.RunResult{Artifact: promptkit.Artifact{Body: []byte("body")}, Validation: promptkit.ValidationResult{Status: status}, Usage: promptkit.TokenUsage{PromptTokens: 7}}, nil
|
||||
return &promptkit.RunResult{Artifact: promptkit.Artifact{Body: []byte("body")}, Validation: promptkit.ValidationResult{Status: status}, Usage: promptkit.TokenUsage{PromptTokens: 7, ReasoningTokens: 3}, CostUSD: promptkit.ObservedCost{Value: 0.25, Known: true}}, nil
|
||||
})
|
||||
w := httptest.NewRecorder()
|
||||
NewHandler(runner).ServeHTTP(w, httptest.NewRequest(http.MethodPost, "/v1/runs", strings.NewReader(tc.body)))
|
||||
@@ -93,6 +93,9 @@ func TestHandlerExecutionReportOptInAndResultShapes(t *testing.T) {
|
||||
if response["metadata"].(map[string]any)["usage"].(map[string]any)["prompt_tokens"] != float64(7) {
|
||||
t.Fatalf("metadata usage changed: %#v", response["metadata"])
|
||||
}
|
||||
if strings.Contains(w.Body.String(), "reasoning_tokens") || strings.Contains(w.Body.String(), "cost_usd") || strings.Contains(w.Body.String(), "message_content_hash") {
|
||||
t.Fatalf("unexpected expanded HTTP fields: %s", w.Body.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1903,9 +1906,15 @@ func newHandlerEngineFromDirectories(t *testing.T, promptDir, profileDir string,
|
||||
if err != nil {
|
||||
t.Fatalf("load profile inputs: %v", err)
|
||||
}
|
||||
for index := range promptInputs {
|
||||
promptInputs[index].Destination = configkit.Keys("promptkit")
|
||||
}
|
||||
for index := range profileInputs {
|
||||
profileInputs[index].Destination = configkit.Keys("promptkit")
|
||||
}
|
||||
underlays := []configkit.Underlay{{Inputs: promptInputs}, {Inputs: profileInputs}}
|
||||
if backend != nil {
|
||||
underlays = append(underlays, configkit.Underlay{Inputs: []configkit.Input{{Source: promptkit.BackendSource("test backend", []promptkit.BackendConfig{*backend})}}})
|
||||
underlays = append(underlays, configkit.Underlay{Inputs: []configkit.Input{promptkit.SettingsInput(promptkit.BackendSource("test backend", []promptkit.BackendConfig{*backend}))}})
|
||||
}
|
||||
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{
|
||||
|
||||
Reference in New Issue
Block a user