Verify resource inspection isolation and selection
This commit is contained in:
@@ -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"})
|
||||
|
||||
Reference in New Issue
Block a user