54 lines
1.6 KiB
Go
54 lines
1.6 KiB
Go
package llm
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"testing/fstest"
|
|
)
|
|
|
|
func TestApplicationAssetsComposeStrictlyBeforeOperatorOverlay(t *testing.T) {
|
|
for _, conflict := range []bool{false, true} {
|
|
t.Run(fmt.Sprint("conflict=", conflict), func(t *testing.T) {
|
|
registry := NewAssetRegistry()
|
|
for _, id := range []string{"first", "second"} {
|
|
if conflict {
|
|
id = "first"
|
|
}
|
|
files := fstest.MapFS{"profiles.yaml": {Data: []byte(fmt.Sprintf("profiles:\n %s:\n backend: openrouter\n model: openai/gpt-5.6-luna\n", id))}}
|
|
if err := registry.RegisterFallbackProfileFS(files, "."); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
operator := filepath.Join(t.TempDir(), "operator.yml")
|
|
if err := os.WriteFile(operator, []byte("profiles:\n first:\n api_key_required: false\n"), 0600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
inspector, err := NewPromptKitProfileInspector(PromptKitProfileInspectorConfig{Assets: registry, Source: PromptKitProfileSourceConfig{ProfileFile: operator}})
|
|
if conflict {
|
|
if err == nil {
|
|
t.Fatal("conflicting application profiles were silently overlaid")
|
|
}
|
|
return
|
|
}
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, id := range []string{"first", "second"} {
|
|
profile, err := inspector.InspectProfile(context.Background(), id)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if profile.Model != "openai/gpt-5.6-luna" || profile.BackendID != "openrouter" {
|
|
t.Fatalf("profile = %#v", profile)
|
|
}
|
|
if id == "first" && profile.CredentialRequired {
|
|
t.Fatal("operator overlay was not applied")
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|