Capture provider policy in backend execution targets
This commit is contained in:
@@ -59,6 +59,35 @@ func TestTargetResolutionNormalizesNestedValues(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestProviderPolicyCaptureAndInspection(t *testing.T) {
|
||||
state, err := load(mapping("provider policy", map[string]any{
|
||||
"collections": map[string]any{"team": map[string]any{
|
||||
"backends": []any{map[string]any{"id": "renamed", "endpoint": "https://example.invalid/v1", "provider": "OPENROUTER", "zero_cost": true}, map[string]any{"id": "child", "extends": map[string]any{"id": "renamed"}, "zero_cost": false}},
|
||||
"profiles": []any{map[string]any{"id": "selected", "backend": "team/child", "endpoint": "https://other.invalid/v1", "model": "m"}},
|
||||
}},
|
||||
"profiles": []any{map[string]any{"id": "generic", "endpoint": "https://example.invalid/v1", "model": "m"}},
|
||||
}), nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
backend, err := state.GetBackend("team/child")
|
||||
if err != nil || backend.Provider != "openrouter" || backend.ZeroCost {
|
||||
t.Fatalf("backend: %+v, %v", backend, err)
|
||||
}
|
||||
profile, err := state.GetProfile(context.Background(), "team/selected")
|
||||
if err != nil || profile.ResolvedTarget.Provider != "openrouter" || profile.ResolvedTarget.ZeroCost || profile.ResolvedTarget.Endpoint != "https://other.invalid/v1" {
|
||||
t.Fatalf("profile: %+v, %v", profile, err)
|
||||
}
|
||||
profile, err = state.GetProfile(context.Background(), "generic")
|
||||
if err != nil || profile.ResolvedTarget.Provider != "openai-compatible" || profile.ResolvedTarget.ZeroCost {
|
||||
t.Fatalf("generic: %+v, %v", profile, err)
|
||||
}
|
||||
resource, err := state.InspectBackend(context.Background(), "team/child")
|
||||
if err != nil || resource.Provider == nil || *resource.Provider != "openrouter" || resource.ZeroCost == nil || *resource.ZeroCost {
|
||||
t.Fatalf("inspection: %+v, %v", resource, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPromptResolutionNormalizesOutputAndRejectsDuplicateNames(t *testing.T) {
|
||||
definition := map[string]any{
|
||||
"id": "example", "inputs": []any{map[string]any{"name": " document "}},
|
||||
|
||||
Reference in New Issue
Block a user