Migrate facade tests to the new configuration contracts
This commit is contained in:
@@ -41,7 +41,7 @@ func TestProfileEnvironmentLookupAcceptsNonShellNames(t *testing.T) {
|
||||
endpoint, model := "http://example.test/v1", "model"
|
||||
lowerName := name
|
||||
cfg.Sources.Underlays = append(cfg.Sources.Underlays, configkit.Underlay{Inputs: []configkit.Input{{
|
||||
Source: promptkit.ProfileSource("default credentials", []promptkit.ProfileConfig{
|
||||
Destination: configkit.Keys("promptkit"), Source: promptkit.ProfileSource("default credentials", []promptkit.ProfileConfig{
|
||||
{ID: "profile", Endpoint: &endpoint, Model: &model, APIKeyEnv: &lowerName},
|
||||
}),
|
||||
}}})
|
||||
@@ -49,7 +49,7 @@ func TestProfileEnvironmentLookupAcceptsNonShellNames(t *testing.T) {
|
||||
if test.clear {
|
||||
env = ""
|
||||
}
|
||||
cfg.Sources.Main = &configkit.Input{Source: promptkit.ProfileSource("credentials", []promptkit.ProfileConfig{
|
||||
cfg.Sources.Main = &configkit.Input{Destination: configkit.Keys("promptkit"), Source: promptkit.ProfileSource("credentials", []promptkit.ProfileConfig{
|
||||
{ID: "profile", Endpoint: &endpoint, Model: &model, APIKeyEnv: &env},
|
||||
})}
|
||||
var calls int
|
||||
@@ -73,7 +73,7 @@ func TestProfileEnvironmentLookupAcceptsNonShellNames(t *testing.T) {
|
||||
|
||||
func TestPublicConstructionWithLocalBackendAndProgrammaticProfile(t *testing.T) {
|
||||
backendID, model := "workstation", "offline-model"
|
||||
prompt := configkit.Input{Source: configkit.Mapping("prompt", map[string]any{
|
||||
prompt := configkit.Input{Destination: configkit.Keys("promptkit"), Source: configkit.Mapping("prompt", map[string]any{
|
||||
"prompts": []any{map[string]any{
|
||||
"id": "hello",
|
||||
"default_profile": "offline",
|
||||
@@ -86,10 +86,10 @@ func TestPublicConstructionWithLocalBackendAndProgrammaticProfile(t *testing.T)
|
||||
localBackend.ID = backendID
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{
|
||||
Underlays: []configkit.Underlay{{Inputs: []configkit.Input{
|
||||
{Source: promptkit.BackendSource("local backend", []promptkit.BackendConfig{
|
||||
{Destination: configkit.Keys("promptkit"), Source: promptkit.BackendSource("local backend", []promptkit.BackendConfig{
|
||||
localBackend,
|
||||
})},
|
||||
{Source: promptkit.ProfileSource("profile", []promptkit.ProfileConfig{
|
||||
{Destination: configkit.Keys("promptkit"), Source: promptkit.ProfileSource("profile", []promptkit.ProfileConfig{
|
||||
{ID: "offline", Backend: &backendID, Model: &model},
|
||||
})},
|
||||
}}},
|
||||
@@ -116,11 +116,11 @@ func TestFormerCatalogBackendIDsWorkWhenConfigured(t *testing.T) {
|
||||
model := "configured-model"
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{
|
||||
Underlays: []configkit.Underlay{{Inputs: []configkit.Input{
|
||||
{Source: promptkit.BackendSource("application backends", []promptkit.BackendConfig{
|
||||
{Destination: configkit.Keys("promptkit"), Source: promptkit.BackendSource("application backends", []promptkit.BackendConfig{
|
||||
{ID: openRouterID, Endpoint: &openRouterEndpoint},
|
||||
{ID: rakestrawhomeID, Endpoint: &rakestrawhomeEndpoint},
|
||||
})},
|
||||
{Source: promptkit.ProfileSource("application profiles", []promptkit.ProfileConfig{
|
||||
{Destination: configkit.Keys("promptkit"), Source: promptkit.ProfileSource("application profiles", []promptkit.ProfileConfig{
|
||||
{ID: "openrouter-profile", Backend: &openRouterID, Model: &model},
|
||||
{ID: "rakestrawhome-profile", Backend: &rakestrawhomeID, Model: &model},
|
||||
})},
|
||||
@@ -170,7 +170,7 @@ prompts:
|
||||
t.Fatalf("select operator inputs: %v", err)
|
||||
}
|
||||
programmaticModel, programmaticEndpoint := "programmatic-model", "https://example.invalid/v1"
|
||||
programmatic := configkit.Input{Source: promptkit.ProfileSource("programmatic settings", []promptkit.ProfileConfig{
|
||||
programmatic := configkit.Input{Destination: configkit.Keys("promptkit"), Source: promptkit.ProfileSource("programmatic settings", []promptkit.ProfileConfig{
|
||||
{ID: "application", Endpoint: &programmaticEndpoint, Model: &programmaticModel},
|
||||
})}
|
||||
for _, test := range []struct {
|
||||
@@ -183,9 +183,9 @@ prompts:
|
||||
{name: "programmatic", apply: true, want: "programmatic-model"},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
underlays := []configkit.Underlay{{Inputs: embedded}}
|
||||
underlays := []configkit.Underlay{{Inputs: mountSettingsInputs(embedded)}}
|
||||
if test.apply {
|
||||
underlays = append(underlays, configkit.Underlay{Inputs: operator})
|
||||
underlays = append(underlays, configkit.Underlay{Inputs: mountSettingsInputs(operator)})
|
||||
}
|
||||
if test.name == "programmatic" {
|
||||
underlays = append(underlays, configkit.Underlay{Inputs: []configkit.Input{programmatic}})
|
||||
@@ -207,7 +207,7 @@ prompts:
|
||||
|
||||
func TestPublicConstructionPreservesConfigKitLoadError(t *testing.T) {
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{Main: &configkit.Input{
|
||||
Source: configkit.Mapping("invalid", map[string]any{"profiles": []any{map[string]any{"id": "broken", "unknown": true}}}),
|
||||
Destination: configkit.Keys("promptkit"), Source: configkit.Mapping("invalid", map[string]any{"prompts": []any{map[string]any{"id": "broken", "output": map[string]any{"unknown": true}}}}),
|
||||
}}})
|
||||
var loadErr *configkit.LoadError
|
||||
if engine != nil || !errors.Is(err, promptkit.ErrInvalidConfig) || !errors.As(err, &loadErr) {
|
||||
@@ -257,10 +257,10 @@ func TestPublicConstructionUsesProgrammaticBackendAndProfileSources(t *testing.T
|
||||
endpoint, backendID, model := "http://application.example/v1", "application-backend", "synthetic-model"
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{
|
||||
Underlays: []configkit.Underlay{{Inputs: []configkit.Input{
|
||||
{Source: promptkit.BackendSource("operator backend", []promptkit.BackendConfig{
|
||||
{Destination: configkit.Keys("promptkit"), Source: promptkit.BackendSource("operator backend", []promptkit.BackendConfig{
|
||||
{ID: backendID, Endpoint: &endpoint},
|
||||
})},
|
||||
{Source: promptkit.ProfileSource("operator profile", []promptkit.ProfileConfig{
|
||||
{Destination: configkit.Keys("promptkit"), Source: promptkit.ProfileSource("operator profile", []promptkit.ProfileConfig{
|
||||
{ID: "application-profile", Backend: &backendID, Model: &model},
|
||||
})},
|
||||
}}},
|
||||
@@ -304,7 +304,7 @@ func TestBackendSourceOwnsSmokeTestValuesAndDefersDefaultLookup(t *testing.T) {
|
||||
authenticationEndpoint = "https://mutated.example/key"
|
||||
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{
|
||||
Underlays: []configkit.Underlay{{Inputs: []configkit.Input{{Source: source}}}},
|
||||
Underlays: []configkit.Underlay{{Inputs: []configkit.Input{{Destination: configkit.Keys("promptkit"), Source: source}}}},
|
||||
}})
|
||||
if err != nil {
|
||||
t.Fatalf("construct engine with dangling diagnostic default: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user