Files
promptkit/internal/domain/smoke_diagnostics_test.go

40 lines
1.3 KiB
Go

package domain
import "testing"
func TestCloneBackendCopiesDiagnosticMetadataAndProviderValues(t *testing.T) {
profile := "profile"
reachabilityEndpoint := "https://probe.example/health"
authKind := "openrouter_key"
authEndpoint := "https://probe.example/key"
backend := Backend{
ExtraParams: map[string]any{"nested": map[string]any{"value": "original"}},
SmokeTests: &BackendSmokeTestConfig{
DefaultProfile: &profile,
Reachability: &ReachabilityProbeConfig{Endpoint: &reachabilityEndpoint},
Authentication: &AuthenticationProbeConfig{
Kind: &authKind,
Endpoint: &authEndpoint,
},
},
}
cloned, err := CloneBackend(backend)
if err != nil {
t.Fatal(err)
}
*cloned.SmokeTests.DefaultProfile = "changed"
*cloned.SmokeTests.Reachability.Endpoint = "changed"
*cloned.SmokeTests.Authentication.Kind = "changed"
*cloned.SmokeTests.Authentication.Endpoint = "changed"
cloned.ExtraParams["nested"].(map[string]any)["value"] = "changed"
if profile != "profile" || reachabilityEndpoint != "https://probe.example/health" ||
authKind != "openrouter_key" || authEndpoint != "https://probe.example/key" {
t.Fatal("cloned diagnostic metadata shared source pointers")
}
if got := backend.ExtraParams["nested"].(map[string]any)["value"]; got != "original" {
t.Fatalf("source provider parameter changed through clone: %v", got)
}
}