Capture schema roots from configuration sources
This commit is contained in:
22
schema_root_source_test.go
Normal file
22
schema_root_source_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user