Update configuration and engine fixtures for identified resources
This commit is contained in:
@@ -300,11 +300,11 @@ func TestLoadChecksOptionalConfigurationVersion(t *testing.T) {
|
||||
include bool
|
||||
valid bool
|
||||
}{
|
||||
{name: "string one", version: "1", include: true, valid: true},
|
||||
{name: "integer one", version: int64(1), include: true, valid: true},
|
||||
{name: "string two", version: "2", include: true, valid: true},
|
||||
{name: "integer two", version: int64(2), include: true, valid: true},
|
||||
{name: "omitted", valid: true},
|
||||
{name: "explicit null", include: true},
|
||||
{name: "unsupported string", version: "2", include: true},
|
||||
{name: "unsupported string", version: "1", include: true},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
values := map[string]any{}
|
||||
@@ -316,8 +316,8 @@ func TestLoadChecksOptionalConfigurationVersion(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("load accepted version: %v", err)
|
||||
}
|
||||
if test.include && (loaded.result.Config.Version == nil || *loaded.result.Config.Version != "1") {
|
||||
t.Fatalf("typed version = %v, want 1", loaded.result.Config.Version)
|
||||
if test.include && (loaded.result.Config.Version == nil || *loaded.result.Config.Version != "2") {
|
||||
t.Fatalf("typed version = %v, want 2", loaded.result.Config.Version)
|
||||
}
|
||||
if !test.include && loaded.result.Config.Version != nil {
|
||||
t.Fatalf("omitted version = %q, want nil", *loaded.result.Config.Version)
|
||||
@@ -328,9 +328,6 @@ func TestLoadChecksOptionalConfigurationVersion(t *testing.T) {
|
||||
if err == nil || !errors.As(err, &loadErr) {
|
||||
t.Fatalf("load error = %v, want ConfigKit load error", err)
|
||||
}
|
||||
if strings.Contains(err.Error(), "2") {
|
||||
t.Fatalf("load error disclosed the unsupported value: %v", err)
|
||||
}
|
||||
found := false
|
||||
for _, diagnostic := range loadErr.Diagnostics() {
|
||||
if diagnostic.Path.String() == "/version" && diagnostic.Message == "unsupported configuration specification version" {
|
||||
@@ -344,9 +341,28 @@ func TestLoadChecksOptionalConfigurationVersion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadRejectsMalformedHeadersAndLegacyResourceMappings(t *testing.T) {
|
||||
for name, values := range map[string]map[string]any{
|
||||
"boolean header": {"version": true},
|
||||
"fractional header": {"version": 2.5},
|
||||
"sequence header": {"version": []any{2}},
|
||||
"backend mapping": {"backends": map[string]any{"local": map[string]any{"endpoint": "https://example.invalid/v1"}}},
|
||||
"profile mapping": {"profiles": map[string]any{"local": map[string]any{}}},
|
||||
"prompt mapping": {"prompts": map[string]any{"local": map[string]any{}}},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
_, err := load(mapping(name, values), nil)
|
||||
var loadErr *configkit.LoadError
|
||||
if !errors.As(err, &loadErr) || len(loadErr.Diagnostics()) == 0 {
|
||||
t.Fatalf("load error = %v, want structured rejection", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadConsumesAcceptedUnderlayVersionAndValidatesHeaderlessPayload(t *testing.T) {
|
||||
underlay := mapping("declared underlay", map[string]any{
|
||||
"version": int64(1),
|
||||
"version": int64(2),
|
||||
})
|
||||
loaded, err := load(mapping("headerless main", map[string]any{}), []configkit.Underlay{{Inputs: []configkit.Input{underlay}}})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user