Define identified configuration resources
This commit is contained in:
@@ -12,6 +12,27 @@ func mapping(label string, values map[string]any) configkit.Input {
|
||||
return configkit.Input{Source: configkit.Mapping(label, values)}
|
||||
}
|
||||
|
||||
func TestLoadIdentifiedResourceLists(t *testing.T) {
|
||||
for _, header := range []bool{false, true} {
|
||||
values := map[string]any{
|
||||
"backends": []any{map[string]any{"id": "local", "endpoint": "https://example.invalid/v1"}},
|
||||
"collections": map[string]any{"team": map[string]any{
|
||||
"backends": []any{map[string]any{"id": "local", "endpoint": "https://example.invalid/v1"}},
|
||||
}},
|
||||
}
|
||||
if header {
|
||||
values["version"] = "2"
|
||||
}
|
||||
loaded, err := load(mapping("identified resources", values), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("load identified resources with header %t: %v", header, err)
|
||||
}
|
||||
if loaded.result.Config.Backends[0].ID != "local" || loaded.result.Config.Collections["team"].Backends[0].ID != "local" {
|
||||
t.Fatal("identified root and collection resources were not retained")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadChecksOptionalConfigurationVersion(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user