Files
notarius/internal/framework/llm/asset_registry_sources_test.go

55 lines
1.6 KiB
Go

package llm
import (
"testing"
"testing/fstest"
)
func TestPromptKitConfigurationSourcesKeepsNativeFilesystemGroups(t *testing.T) {
registry := NewAssetRegistry()
for index, name := range []string{"first", "second"} {
files := fstest.MapFS{
"prompts/prompt.yaml": {Data: []byte("prompts: {}\n")},
}
if err := registry.RegisterPromptFS(files, "."); err != nil {
t.Fatalf("register prompt source %d (%s): %v", index, name, err)
}
}
fallbackProfiles := fstest.MapFS{
"profiles.yaml": {Data: []byte("profiles: {}\n")},
}
if err := registry.RegisterFallbackProfileFS(fallbackProfiles, "."); err != nil {
t.Fatal(err)
}
schemas := fstest.MapFS{"schema.json": {Data: []byte(`{"type":"object"}`)}}
if err := registry.RegisterSchemaFS(schemas, "."); err != nil {
t.Fatal(err)
}
sources, options, err := registry.PromptKitConfigurationSources()
if err != nil {
t.Fatal(err)
}
if sources.Main != nil {
t.Fatalf("maintained sources unexpectedly set a main input: %+v", sources.Main)
}
if len(sources.Underlays) != 3 {
t.Fatalf("underlays = %d, want two prompt groups and one profile group", len(sources.Underlays))
}
for index, underlay := range sources.Underlays {
if len(underlay.Inputs) != 1 {
t.Fatalf("underlay %d has %d inputs, want 1", index, len(underlay.Inputs))
}
input := underlay.Inputs[0]
if input.Imports {
t.Fatalf("maintained input %d unexpectedly enables imports", index)
}
if input.Filesystem == nil || input.Filesystem.FS == nil {
t.Fatalf("maintained input %d has no native filesystem context", index)
}
}
if len(options) != 1 {
t.Fatalf("runtime options = %d, want one schema option", len(options))
}
}