23 lines
732 B
Go
23 lines
732 B
Go
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)
|
|
}
|
|
}
|