Address backend implementation review findings
This commit is contained in:
@@ -154,6 +154,7 @@ func TestCustomBackendFlowsThroughProfilesOverridesAndInjectedClient(t *testing.
|
||||
promptkit.WithProfiles(
|
||||
promptkit.Profile{ID: "backend-profile", BackendID: "custom", Model: "backend-model"},
|
||||
promptkit.Profile{ID: "profile-endpoint", BackendID: "custom", Endpoint: "http://profile.example/v1", Model: "profile-model"},
|
||||
promptkit.Profile{ID: "blank-profile-endpoint", BackendID: "custom", Endpoint: " \t ", Model: "profile-model"},
|
||||
),
|
||||
promptkit.WithLLMClient(client),
|
||||
)
|
||||
@@ -188,6 +189,16 @@ func TestCustomBackendFlowsThroughProfilesOverridesAndInjectedClient(t *testing.
|
||||
t.Fatalf("profile endpoint override changed backend identity: %+v", prepared)
|
||||
}
|
||||
|
||||
prepared, err = engine.Prepare(context.Background(), promptkit.RunRequest{
|
||||
PromptID: "prompt", ProfileID: "blank-profile-endpoint",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("prepare blank profile endpoint: %v", err)
|
||||
}
|
||||
if prepared.SelectedBackendID != "custom" || prepared.EffectiveModelParams.Endpoint != "http://backend.example/v1" {
|
||||
t.Fatalf("blank profile endpoint did not inherit backend endpoint: %+v", prepared)
|
||||
}
|
||||
|
||||
prepared, err = engine.Prepare(context.Background(), promptkit.RunRequest{
|
||||
PromptID: "prompt",
|
||||
Execution: &promptkit.ExecutionTargetOverride{
|
||||
@@ -208,6 +219,7 @@ func TestCustomBackendSupportsFileProfileAndBothSelectionPaths(t *testing.T) {
|
||||
promptkit.WithProfileFS(fstest.MapFS{
|
||||
"profile.yaml": &fstest.MapFile{Data: []byte(`id: file-profile
|
||||
backend: file-backend
|
||||
endpoint: " "
|
||||
model: file-model
|
||||
`)},
|
||||
}, "."),
|
||||
@@ -303,6 +315,7 @@ func TestBackendRegistrationRejectsInvalidAndDuplicateDefinitions(t *testing.T)
|
||||
{name: "invalid environment", backends: []promptkit.Backend{{ID: "custom", Endpoint: "http://example.test/v1", APIKeyEnv: "BAD-NAME"}}},
|
||||
{name: "reserved extra parameter", backends: []promptkit.Backend{{ID: "custom", Endpoint: "http://example.test/v1", ExtraParams: map[string]any{"model": "override"}}}},
|
||||
{name: "cyclic extra parameter", backends: []promptkit.Backend{{ID: "custom", Endpoint: "http://example.test/v1", ExtraParams: cycle}}},
|
||||
{name: "malformed JSON number", backends: []promptkit.Backend{{ID: "custom", Endpoint: "http://example.test/v1", ExtraParams: map[string]any{"value": json.Number("01")}}}},
|
||||
{name: "duplicate consumer id", backends: []promptkit.Backend{
|
||||
{ID: " custom ", Endpoint: "http://one.example/v1"},
|
||||
{ID: "custom", Endpoint: "http://two.example/v1"},
|
||||
|
||||
Reference in New Issue
Block a user