Add item registry extraction and validation

This commit is contained in:
2026-08-05 19:27:49 +00:00
parent ce04387dbc
commit ad9ee076b5
19 changed files with 1204 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package itemregistry
import (
"encoding/json"
"strings"
"testing"
)
func TestItemResponseSchemaIsPrivateAndStructural(t *testing.T) {
schema, err := loadResponseSchema()
if err != nil {
t.Fatalf("loadResponseSchema() error = %v", err)
}
if schema.Key != ResponseSchemaKey || schema.ID != ResponseSchemaID || schema.Name != ResponseSchemaName || schema.Version != SchemaVersion || !strings.HasPrefix(schema.SHA256, "sha256:") || !json.Valid(schema.JSONSchema) {
t.Fatalf("schema = %#v, want item response schema", schema)
}
var document map[string]any
if err := json.Unmarshal(schema.JSONSchema, &document); err != nil {
t.Fatal(err)
}
encoded, err := json.Marshal(document)
if err != nil || strings.Contains(string(encoded), `"id"`) || !strings.Contains(string(encoded), `"additionalProperties":false`) {
t.Fatalf("schema = %s, want strict private response without durable ID", encoded)
}
}