Simplify diagnostic report ownership

This commit is contained in:
2026-11-05 14:21:33 +00:00
parent f745b14b71
commit 68668cee56
6 changed files with 36 additions and 176 deletions

View File

@@ -1,9 +1,6 @@
package domain
import (
"testing"
"time"
)
import "testing"
func TestCloneBackendCopiesDiagnosticMetadataAndProviderValues(t *testing.T) {
profile := "profile"
@@ -40,73 +37,3 @@ func TestCloneBackendCopiesDiagnosticMetadataAndProviderValues(t *testing.T) {
t.Fatalf("source provider parameter changed through clone: %v", got)
}
}
func TestCloneSmokeTestRequestOwnsOptionalSettings(t *testing.T) {
temperature := 0.25
retries := 2
reasoning := "low"
request := SmokeTestRequest{
APIKey: "secret",
TransientRetries: &retries,
Execution: &ExecutionTargetOverride{
Temperature: &temperature,
ReasoningEffort: &reasoning,
ExtraParams: map[string]any{"nested": map[string]any{"value": "original"}},
},
}
cloned, err := CloneSmokeTestRequest(request)
if err != nil {
t.Fatal(err)
}
*cloned.TransientRetries = 3
*cloned.Execution.Temperature = 0.5
*cloned.Execution.ReasoningEffort = "high"
cloned.Execution.ExtraParams["nested"].(map[string]any)["value"] = "changed"
if retries != 2 || temperature != 0.25 || reasoning != "low" {
t.Fatal("cloned request shared optional scalar pointers")
}
if got := request.Execution.ExtraParams["nested"].(map[string]any)["value"]; got != "original" {
t.Fatalf("source provider parameter changed through clone: %v", got)
}
}
func TestCloneSmokeTestReportOwnsMutableValues(t *testing.T) {
applicable := true
reachable := true
status := 200
wait := 3 * time.Millisecond
report := SmokeTestReport{
Applicable: &applicable,
Target: SmokeTestTarget{
EffectiveSettings: ExecutionTarget{
ExtraParams: map[string]any{"nested": map[string]any{"value": "original"}},
},
},
Facts: SmokeTestFacts{EndpointReachable: &reachable},
Attempts: []SmokeTestAttempt{{
HTTPStatus: &status,
Facts: SmokeTestFacts{EndpointReachable: &reachable},
Timing: SmokeTestTiming{CapacityWait: &wait},
}},
}
cloned, err := CloneSmokeTestReport(report)
if err != nil {
t.Fatal(err)
}
*cloned.Applicable = false
*cloned.Facts.EndpointReachable = false
*cloned.Attempts[0].HTTPStatus = 503
*cloned.Attempts[0].Facts.EndpointReachable = false
*cloned.Attempts[0].Timing.CapacityWait = time.Second
cloned.Target.EffectiveSettings.ExtraParams["nested"].(map[string]any)["value"] = "changed"
if !applicable || !reachable || status != 200 || wait != 3*time.Millisecond {
t.Fatal("cloned report shared optional scalar pointers")
}
if got := report.Target.EffectiveSettings.ExtraParams["nested"].(map[string]any)["value"]; got != "original" {
t.Fatalf("source provider parameter changed through clone: %v", got)
}
}