Complete input destination implementation audit
This commit is contained in:
@@ -153,6 +153,36 @@ func TestFacadeImportedSourcesRetainInputDestination(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFacadeSameFragmentMountsAtSeparateCollectionDestinations(t *testing.T) {
|
||||
weatherDestination := configkit.Keys("collections", "weather", "prompts")
|
||||
homeDestination := configkit.Keys("collections", "homewatch", "prompts")
|
||||
result, err := configkit.LoadLayered(
|
||||
configkit.Input{Source: configkit.NoSource()},
|
||||
configkit.LayeredOptions[map[string]any]{Underlays: []configkit.Underlay{{Inputs: []configkit.Input{
|
||||
{Source: configkit.Bytes("weather", []byte("summarize.alerts: {title: weather}\n")), Destination: weatherDestination},
|
||||
{Source: configkit.Bytes("homewatch", []byte("summarize.alerts: {title: home}\n")), Destination: homeDestination},
|
||||
}}}},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("LoadLayered: %v", err)
|
||||
}
|
||||
for _, test := range []struct {
|
||||
path []string
|
||||
want string
|
||||
}{
|
||||
{path: []string{"collections", "weather", "prompts", "summarize.alerts", "title"}, want: "weather"},
|
||||
{path: []string{"collections", "homewatch", "prompts", "summarize.alerts", "title"}, want: "home"},
|
||||
} {
|
||||
if got := facadeDestinationValue(t, result.Config, test.path...); got != test.want {
|
||||
t.Errorf("value at %v = %#v, want %q", test.path, got, test.want)
|
||||
}
|
||||
}
|
||||
sources := result.Sources()
|
||||
if len(sources) != 2 || sources[0].Destination.String() != weatherDestination.String() || sources[1].Destination.String() != homeDestination.String() {
|
||||
t.Fatalf("independent collection source placements = %#v", sources)
|
||||
}
|
||||
}
|
||||
|
||||
type destinationCountingReader struct{ reads int }
|
||||
|
||||
func (reader *destinationCountingReader) Read([]byte) (int, error) {
|
||||
|
||||
Reference in New Issue
Block a user