Consolidate bundled catalog test expectations
This commit is contained in:
@@ -2,8 +2,8 @@ package promptkit_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"reflect"
|
||||||
"strings"
|
"slices"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"go.maximumdirect.net/configkit"
|
"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" {
|
if target := inspect("openrouter/profile"); target.BackendID != "openrouter/local" || target.Model != "collection-model" {
|
||||||
t.Fatalf("collection = %+v", target)
|
t.Fatalf("collection = %+v", target)
|
||||||
}
|
}
|
||||||
for _, tier := range []string{"low", "medium", "high", "xhigh", "max"} {
|
target := inspect("auto-low")
|
||||||
target := inspect("auto-" + tier)
|
wantPlugins := map[string]any{"plugins": []any{map[string]any{"id": "auto-router", "cost_tier": "low"}}}
|
||||||
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") {
|
if target.BackendID != "other" || target.Model != "other-model" || !reflect.DeepEqual(target.ExtraParams, wantPlugins) {
|
||||||
t.Errorf("tier %s = %+v", tier, target)
|
t.Errorf("inherited tier = %+v", target)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,11 +69,11 @@ func TestBundledCompositionSequenceModes(t *testing.T) {
|
|||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
name, mode, id string
|
name, mode, id string
|
||||||
wantErr bool
|
wantErr bool
|
||||||
count int
|
hasAuto bool
|
||||||
}{
|
}{
|
||||||
{"duplicate append", "append", "auto", true, 0},
|
{"duplicate append", "append", "auto", true, false},
|
||||||
{"distinct append", "append", "custom", false, 18},
|
{"distinct append", "append", "custom", false, true},
|
||||||
{"replace", "replace", "custom", false, 1},
|
{"replace", "replace", "custom", false, false},
|
||||||
} {
|
} {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
input := configkit.Input{Source: configkit.Mapping("sequence", map[string]any{
|
input := configkit.Input{Source: configkit.Mapping("sequence", map[string]any{
|
||||||
@@ -92,7 +91,7 @@ func TestBundledCompositionSequenceModes(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
profiles, err := engine.ListProfiles(context.Background())
|
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)
|
t.Fatalf("profiles = %v, %v", profiles, err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ func TestBundledProfilePreparationAndExecution(t *testing.T) {
|
|||||||
func TestBundledProfileHTTPPayloads(t *testing.T) {
|
func TestBundledProfileHTTPPayloads(t *testing.T) {
|
||||||
t.Setenv("OPENROUTER_API_KEY", "synthetic-key")
|
t.Setenv("OPENROUTER_API_KEY", "synthetic-key")
|
||||||
for _, test := range []struct{ id, model, tier string }{
|
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-low", "openrouter/auto", "low"}, {"gpt-luna-latest", "~openai/gpt-luna-latest", ""},
|
||||||
{"auto", "openrouter/auto", ""}, {"free", "openrouter/free", ""}, {"gpt-luna-latest", "~openai/gpt-luna-latest", ""},
|
|
||||||
} {
|
} {
|
||||||
t.Run(test.id, func(t *testing.T) {
|
t.Run(test.id, func(t *testing.T) {
|
||||||
var body map[string]any
|
var body map[string]any
|
||||||
|
|||||||
@@ -51,23 +51,16 @@ func TestBundledOpenRouterOptionsAndInventory(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
want := 0
|
if (len(profiles) > 0) != test.enabled || len(backends) != boolCount(test.enabled) || len(prompts) != 0 || len(collections) != 0 {
|
||||||
if test.enabled {
|
|
||||||
want = 17
|
|
||||||
}
|
|
||||||
if len(profiles) != want || len(backends) != boolCount(test.enabled) || len(prompts) != 0 || len(collections) != 0 {
|
|
||||||
t.Fatalf("inventories: %v %v %v %v", profiles, backends, prompts, collections)
|
t.Fatalf("inventories: %v %v %v %v", profiles, backends, prompts, collections)
|
||||||
}
|
}
|
||||||
if test.enabled {
|
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(backends, []string{"openrouter"}) {
|
||||||
if !reflect.DeepEqual(profiles, wantProfiles) || !reflect.DeepEqual(backends, []string{"openrouter"}) {
|
|
||||||
t.Fatalf("bundle inventory: %v %v", profiles, backends)
|
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(), "auto")
|
||||||
profile, err := engine.InspectProfile(context.Background(), id)
|
if err != nil || profile.EffectiveModelParams.BackendID != "openrouter" {
|
||||||
if err != nil || profile.EffectiveModelParams.Model != model || profile.EffectiveModelParams.BackendID != "openrouter" {
|
t.Fatalf("bundle profile = %+v, %v", profile, err)
|
||||||
t.Fatalf("profile %s = %+v, %v", id, profile, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
view, err := engine.InspectConfiguration()
|
view, err := engine.InspectConfiguration()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -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
|
**Validation/outcome:** Focused internal bundle and public option/wire/smoke tests
|
||||||
retain assembled behavior with a single complete maintained-asset oracle.
|
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
|
## Stage 29: Test Artifact Hashes As Opaque Values
|
||||||
|
|
||||||
**Catalog:** 29. **Scope:** artifact tests and benchmark correctness setup.
|
**Catalog:** 29. **Scope:** artifact tests and benchmark correctness setup.
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package configuration
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"go.maximumdirect.net/configkit"
|
"go.maximumdirect.net/configkit"
|
||||||
|
"go.maximumdirect.net/promptkit/internal/defaults"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBundledOpenRouterUnderlay(t *testing.T) {
|
func TestBundledOpenRouterUnderlay(t *testing.T) {
|
||||||
@@ -15,9 +17,12 @@ func TestBundledOpenRouterUnderlay(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
backend, err := state.GetBackend("openrouter")
|
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)
|
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{
|
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",
|
"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",
|
"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 {
|
for id, model := range models {
|
||||||
profile, err := state.GetProfile(context.Background(), id)
|
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)
|
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 {
|
if tier, ok := strings.CutPrefix(id, "auto-"); ok {
|
||||||
plugins := fmt.Sprint(profile.ResolvedTarget.ExtraParams)
|
want.ExtraParams = map[string]any{"plugins": []any{map[string]any{"id": "auto-router", "cost_tier": tier}}}
|
||||||
if !strings.Contains(plugins, "cost_tier:"+tier) || !strings.Contains(plugins, "id:auto-router") {
|
}
|
||||||
t.Fatalf("profile %s plugins = %+v", id, profile.ResolvedTarget.ExtraParams)
|
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") {
|
if !strings.Contains(fmt.Sprint(state.result.Sources()), "Promptkit bundled OpenRouter") {
|
||||||
|
|||||||
Reference in New Issue
Block a user