Capture schema roots from configuration sources

This commit is contained in:
2026-11-20 15:25:00 +00:00
parent fbe3d427a2
commit 596e985cff
11 changed files with 204 additions and 100 deletions

View File

@@ -0,0 +1,22 @@
package promptkit
import (
"testing"
"go.maximumdirect.net/configkit"
)
func TestSchemaRootSourceUsesNativeLayerPrecedence(t *testing.T) {
type document struct {
SchemaRoot *string `yaml:"schema_root"`
}
underlay := configkit.Input{Source: SchemaRootSource("defaults", "defaults")}
main := configkit.Input{Source: configkit.Mapping("operator", map[string]any{"schema_root": "operator"})}
result, err := configkit.LoadLayered(main, configkit.LayeredOptions[document]{Underlays: []configkit.Underlay{{Inputs: []configkit.Input{underlay}}}})
if err != nil {
t.Fatal(err)
}
if result.Config.SchemaRoot == nil || *result.Config.SchemaRoot != "operator" {
t.Fatalf("effective root = %v", result.Config.SchemaRoot)
}
}