Moved JSON response schemas into separate files

This commit is contained in:
2026-05-24 06:51:50 -05:00
parent 99ab2f181b
commit 3a0a0b3940
4 changed files with 114 additions and 6 deletions

View File

@@ -1,14 +1,16 @@
package responseschema
import (
"bytes"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"testing"
)
const (
expectedCorrectionSetSHA256 = "05f8ff3fa04f68115c0cb1859d2656f51aa5c0bae8ff2470b2d4f6f531953195"
expectedValidatorDecisionSetSHA256 = "b73f4790b98fbb955f0aec5496dd8ce9a8fe14aa2f35c700b4b4e5634f106fd5"
expectedCorrectionSetSHA256 = "b86a2dde38d7f440d26470fa8830167512bb0aa1b35e5fee5547057be583c388"
expectedValidatorDecisionSetSHA256 = "2fe90d450e2595b57885aba91c8cc5cedf783dd36758ab430309e3eace401f54"
)
func TestLookupKnownSchemas(t *testing.T) {
@@ -47,6 +49,20 @@ func TestLookupUnknownSchema(t *testing.T) {
}
}
func TestRegisteredSchemasLoadReadableEmbeddedJSON(t *testing.T) {
for _, schema := range Registered() {
if len(schema.JSONSchema) == 0 {
t.Fatalf("expected non-empty JSON schema for %q", schema.ID)
}
if !json.Valid(schema.JSONSchema) {
t.Fatalf("expected valid JSON schema for %q", schema.ID)
}
if !bytes.Contains(schema.JSONSchema, []byte("\n ")) {
t.Fatalf("expected readable formatted JSON schema for %q", schema.ID)
}
}
}
func TestSchemaHashesMatchRegisteredJSON(t *testing.T) {
expectedByKey := map[Key]string{
CorrectionSetKey: expectedCorrectionSetSHA256,