Verify resource inspection isolation and selection

This commit is contained in:
2026-11-06 15:26:16 +00:00
parent b5b9b1f209
commit ea63a7b0ff
3 changed files with 125 additions and 0 deletions

View File

@@ -87,6 +87,26 @@ func TestWithNamespacesRoutesOrdinarySelectionsAndPreservesViews(t *testing.T) {
}
}
func TestInspectBackendNamespaceSelection(t *testing.T) {
engine := newNamespacedContractEngine(t, &fakeLLMClient{})
scoped, err := engine.WithNamespaces(promptkit.Namespaces{Backend: "alpha"})
if err != nil {
t.Fatal(err)
}
for id, want := range map[string]string{"backend": "alpha/backend", "beta/backend": "beta/backend"} {
got, err := scoped.InspectBackend(context.Background(), id)
if err != nil || got.BackendID != want {
t.Errorf("backend %q = %+v, %v", id, got, err)
}
}
if _, err := scoped.InspectBackend(context.Background(), "openrouter"); !errors.Is(err, promptkit.ErrBackendNotFound) {
t.Fatalf("unexpected fallback: %v", err)
}
if got, err := engine.InspectBackend(context.Background(), "openrouter"); err != nil || got.BackendID != "openrouter" {
t.Fatalf("bundled backend = %+v, %v", got, err)
}
}
func TestWithNamespacesHasNoFallbackAndValidatesAtTheCorrectBoundary(t *testing.T) {
engine := newNamespacedContractEngine(t, &fakeLLMClient{response: &promptkit.GenerateResponse{Content: "reply"}})
scoped, err := engine.WithNamespaces(promptkit.Namespaces{Prompt: "alpha", Profile: "alpha"})