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{
|
||||
|
||||
@@ -33,6 +33,7 @@ func TestCollectorProjectsOnlyTerminalAggregates(t *testing.T) {
|
||||
PromptTokens: promptkit.ObservedTokenCount{Value: 0, Known: true, Complete: true},
|
||||
CompletionTokens: promptkit.ObservedTokenCount{Value: 0, Known: false, Complete: false},
|
||||
TotalTokens: promptkit.ObservedTokenCount{Value: 11, Known: true, Complete: false},
|
||||
ReasoningTokens: promptkit.ObservedTokenCount{Value: 3, Known: true, Complete: true},
|
||||
},
|
||||
})
|
||||
collector.Observe(promptkit.ExecutionEvent{Kind: promptkit.ExecutionRetryDelay, Attempts: 50})
|
||||
@@ -70,6 +71,9 @@ func TestCollectorProjectsOnlyTerminalAggregates(t *testing.T) {
|
||||
t.Fatalf("report exposed %q: %s", forbidden, encoded)
|
||||
}
|
||||
}
|
||||
if strings.Contains(string(encoded), "reasoning_tokens") || strings.Contains(string(encoded), "cost_usd") || strings.Contains(string(encoded), "cache_hit_ratio") {
|
||||
t.Fatalf("unexpected report expansion: %s", encoded)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollectorHandlesUnknownValuesAndKeepsInvocationsSeparate(t *testing.T) {
|
||||
@@ -129,6 +133,12 @@ func TestCollectorReceivesRealEngineTerminalEvent(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for index := range promptInputs {
|
||||
promptInputs[index].Destination = configkit.Keys("promptkit")
|
||||
}
|
||||
for index := range profileInputs {
|
||||
profileInputs[index].Destination = configkit.Keys("promptkit")
|
||||
}
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{
|
||||
Sources: promptkit.ConfigurationSources{Underlays: []configkit.Underlay{{Inputs: promptInputs}, {Inputs: profileInputs}}},
|
||||
}, promptkit.WithLLMClient(localClient{}))
|
||||
|
||||
Reference in New Issue
Block a user