From e7a366544354d1f69db40eae16b2b255fc7c7855 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Thu, 5 Nov 2026 14:30:14 +0000 Subject: [PATCH] Consolidate bundled catalog test expectations --- bundled_composition_contract_test.go | 23 +++++++++++------------ bundled_execution_contract_test.go | 3 +-- bundled_openrouter_contract_test.go | 17 +++++------------ docs/roadmap/implementation.md | 5 +++++ internal/configuration/bundled_test.go | 19 +++++++++++++------ 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/bundled_composition_contract_test.go b/bundled_composition_contract_test.go index 85227d9..659a524 100644 --- a/bundled_composition_contract_test.go +++ b/bundled_composition_contract_test.go @@ -2,8 +2,8 @@ package promptkit_test import ( "context" - "fmt" - "strings" + "reflect" + "slices" "testing" "go.maximumdirect.net/configkit" @@ -58,11 +58,10 @@ func TestBundledCompositionReplacementAndInheritance(t *testing.T) { if target := inspect("openrouter/profile"); target.BackendID != "openrouter/local" || target.Model != "collection-model" { t.Fatalf("collection = %+v", target) } - for _, tier := range []string{"low", "medium", "high", "xhigh", "max"} { - target := inspect("auto-" + tier) - if target.BackendID != "other" || target.Model != "other-model" || !strings.Contains(fmt.Sprint(target.ExtraParams), "cost_tier:"+tier) || !strings.Contains(fmt.Sprint(target.ExtraParams), "id:auto-router") { - t.Errorf("tier %s = %+v", tier, target) - } + target := inspect("auto-low") + wantPlugins := map[string]any{"plugins": []any{map[string]any{"id": "auto-router", "cost_tier": "low"}}} + if target.BackendID != "other" || target.Model != "other-model" || !reflect.DeepEqual(target.ExtraParams, wantPlugins) { + t.Errorf("inherited tier = %+v", target) } } @@ -70,11 +69,11 @@ func TestBundledCompositionSequenceModes(t *testing.T) { for _, test := range []struct { name, mode, id string wantErr bool - count int + hasAuto bool }{ - {"duplicate append", "append", "auto", true, 0}, - {"distinct append", "append", "custom", false, 18}, - {"replace", "replace", "custom", false, 1}, + {"duplicate append", "append", "auto", true, false}, + {"distinct append", "append", "custom", false, true}, + {"replace", "replace", "custom", false, false}, } { t.Run(test.name, func(t *testing.T) { input := configkit.Input{Source: configkit.Mapping("sequence", map[string]any{ @@ -92,7 +91,7 @@ func TestBundledCompositionSequenceModes(t *testing.T) { t.Fatal(err) } profiles, err := engine.ListProfiles(context.Background()) - if err != nil || len(profiles) != test.count { + if err != nil || !slices.Contains(profiles, "custom") || slices.Contains(profiles, "auto") != test.hasAuto { t.Fatalf("profiles = %v, %v", profiles, err) } }) diff --git a/bundled_execution_contract_test.go b/bundled_execution_contract_test.go index 4e26910..46ea820 100644 --- a/bundled_execution_contract_test.go +++ b/bundled_execution_contract_test.go @@ -51,8 +51,7 @@ func TestBundledProfilePreparationAndExecution(t *testing.T) { func TestBundledProfileHTTPPayloads(t *testing.T) { t.Setenv("OPENROUTER_API_KEY", "synthetic-key") for _, test := range []struct{ id, model, tier string }{ - {"auto-low", "openrouter/auto", "low"}, {"auto-medium", "openrouter/auto", "medium"}, {"auto-high", "openrouter/auto", "high"}, {"auto-xhigh", "openrouter/auto", "xhigh"}, {"auto-max", "openrouter/auto", "max"}, - {"auto", "openrouter/auto", ""}, {"free", "openrouter/free", ""}, {"gpt-luna-latest", "~openai/gpt-luna-latest", ""}, + {"auto-low", "openrouter/auto", "low"}, {"gpt-luna-latest", "~openai/gpt-luna-latest", ""}, } { t.Run(test.id, func(t *testing.T) { var body map[string]any diff --git a/bundled_openrouter_contract_test.go b/bundled_openrouter_contract_test.go index 7036279..ed64c04 100644 --- a/bundled_openrouter_contract_test.go +++ b/bundled_openrouter_contract_test.go @@ -51,23 +51,16 @@ func TestBundledOpenRouterOptionsAndInventory(t *testing.T) { if err != nil { t.Fatal(err) } - want := 0 - if test.enabled { - want = 17 - } - if len(profiles) != want || len(backends) != boolCount(test.enabled) || len(prompts) != 0 || len(collections) != 0 { + if (len(profiles) > 0) != test.enabled || len(backends) != boolCount(test.enabled) || len(prompts) != 0 || len(collections) != 0 { t.Fatalf("inventories: %v %v %v %v", profiles, backends, prompts, collections) } if test.enabled { - wantProfiles := []string{"auto", "auto-high", "auto-low", "auto-max", "auto-medium", "auto-xhigh", "claude-fable-latest", "claude-haiku-latest", "claude-opus-latest", "claude-sonnet-latest", "free", "gemini-flash-latest", "gemini-pro-latest", "gpt-astra-latest", "gpt-luna-latest", "gpt-sol-latest", "gpt-terra-latest"} - if !reflect.DeepEqual(profiles, wantProfiles) || !reflect.DeepEqual(backends, []string{"openrouter"}) { + if !reflect.DeepEqual(backends, []string{"openrouter"}) { t.Fatalf("bundle inventory: %v %v", profiles, backends) } - for id, model := range map[string]string{"auto": "openrouter/auto", "auto-max": "openrouter/auto", "gpt-luna-latest": "~openai/gpt-luna-latest", "free": "openrouter/free"} { - profile, err := engine.InspectProfile(context.Background(), id) - if err != nil || profile.EffectiveModelParams.Model != model || profile.EffectiveModelParams.BackendID != "openrouter" { - t.Fatalf("profile %s = %+v, %v", id, profile, err) - } + profile, err := engine.InspectProfile(context.Background(), "auto") + if err != nil || profile.EffectiveModelParams.BackendID != "openrouter" { + t.Fatalf("bundle profile = %+v, %v", profile, err) } view, err := engine.InspectConfiguration() if err != nil { diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index b56cf9c..364a0db 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -737,6 +737,11 @@ privacy, profile, inheritance, and provider tests pass on Go 1.27.3. **Validation/outcome:** Focused internal bundle and public option/wire/smoke tests retain assembled behavior with a single complete maintained-asset oracle. +Completion: the configuration bundle test owns the complete inventory, model, +default, and structural plugin expectations. Public tests retain representative +option, composition, wire, and configured-default smoke behavior without a +second catalog matrix. Focused bundle tests pass on Go 1.27.3. + ## Stage 29: Test Artifact Hashes As Opaque Values **Catalog:** 29. **Scope:** artifact tests and benchmark correctness setup. diff --git a/internal/configuration/bundled_test.go b/internal/configuration/bundled_test.go index 0e27bb9..9b002b4 100644 --- a/internal/configuration/bundled_test.go +++ b/internal/configuration/bundled_test.go @@ -3,10 +3,12 @@ package configuration import ( "context" "fmt" + "reflect" "strings" "testing" "go.maximumdirect.net/configkit" + "go.maximumdirect.net/promptkit/internal/defaults" ) func TestBundledOpenRouterUnderlay(t *testing.T) { @@ -15,9 +17,12 @@ func TestBundledOpenRouterUnderlay(t *testing.T) { t.Fatal(err) } backend, err := state.GetBackend("openrouter") - if err != nil || backend.Endpoint != "https://openrouter.ai/api/v1" || backend.APIKeyEnv != "OPENROUTER_API_KEY" || backend.SmokeTests == nil || backend.SmokeTests.DefaultProfile == nil || *backend.SmokeTests.DefaultProfile != "gpt-luna-latest" || backend.SmokeTests.Authentication == nil || *backend.SmokeTests.Authentication.Kind != "openrouter_key" { + if err != nil || backend.Endpoint != "https://openrouter.ai/api/v1" || backend.APIKeyEnv != "OPENROUTER_API_KEY" || backend.SmokeTests == nil || backend.SmokeTests.DefaultProfile == nil || *backend.SmokeTests.DefaultProfile != "gpt-luna-latest" || backend.SmokeTests.Authentication == nil || backend.SmokeTests.Authentication.Kind == nil || *backend.SmokeTests.Authentication.Kind != "openrouter_key" { t.Fatalf("backend = %+v, %v", backend, err) } + if !reflect.DeepEqual(state.backendIDs, []string{"openrouter"}) || len(state.promptIDs) != 0 || len(state.collections) != 0 { + t.Fatalf("bundle inventories: backends=%v prompts=%v collections=%v", state.backendIDs, state.promptIDs, state.collections) + } models := map[string]string{ "gpt-astra-latest": "~openai/gpt-astra-latest", "gpt-sol-latest": "~openai/gpt-sol-latest", "gpt-terra-latest": "~openai/gpt-terra-latest", "gpt-luna-latest": "~openai/gpt-luna-latest", "claude-fable-latest": "~anthropic/claude-fable-latest", "claude-opus-latest": "~anthropic/claude-opus-latest", "claude-sonnet-latest": "~anthropic/claude-sonnet-latest", "claude-haiku-latest": "~anthropic/claude-haiku-latest", @@ -31,14 +36,16 @@ func TestBundledOpenRouterUnderlay(t *testing.T) { } for id, model := range models { profile, err := state.GetProfile(context.Background(), id) - if err != nil || profile.ResolvedTarget.Model != model || profile.ResolvedTarget.BackendID != "openrouter" { + if err != nil { t.Fatalf("profile %s = %+v, %v", id, profile, err) } + want := defaults.ExecutionTargetDefault() + want.Model, want.BackendID, want.Endpoint, want.APIKeyEnv = model, "openrouter", "https://openrouter.ai/api/v1", "OPENROUTER_API_KEY" if tier, ok := strings.CutPrefix(id, "auto-"); ok { - plugins := fmt.Sprint(profile.ResolvedTarget.ExtraParams) - if !strings.Contains(plugins, "cost_tier:"+tier) || !strings.Contains(plugins, "id:auto-router") { - t.Fatalf("profile %s plugins = %+v", id, profile.ResolvedTarget.ExtraParams) - } + want.ExtraParams = map[string]any{"plugins": []any{map[string]any{"id": "auto-router", "cost_tier": tier}}} + } + if !reflect.DeepEqual(*profile.ResolvedTarget, want) { + t.Fatalf("profile %s target = %+v, want %+v", id, *profile.ResolvedTarget, want) } } if !strings.Contains(fmt.Sprint(state.result.Sources()), "Promptkit bundled OpenRouter") {