Centralize output schema names in schema package
This commit is contained in:
@@ -14,6 +14,10 @@ import (
|
||||
var schemaFS embed.FS
|
||||
|
||||
const (
|
||||
OutputSchemaMinimal = "seriatim-minimal"
|
||||
OutputSchemaIntermediate = "seriatim-intermediate"
|
||||
OutputSchemaFull = "seriatim-full"
|
||||
|
||||
fullOutputSchemaPath = "full-output.schema.json"
|
||||
intermediateOutputSchemaPath = "intermediate-output.schema.json"
|
||||
minimalOutputSchemaPath = "minimal-output.schema.json"
|
||||
@@ -115,6 +119,25 @@ type OverlapGroup struct {
|
||||
Resolution string `json:"resolution"`
|
||||
}
|
||||
|
||||
// ValidOutputSchemaName reports whether value is a supported output schema name.
|
||||
func ValidOutputSchemaName(value string) bool {
|
||||
switch value {
|
||||
case OutputSchemaMinimal, OutputSchemaIntermediate, OutputSchemaFull:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// OutputSchemaNames returns supported output schema names in validation order.
|
||||
func OutputSchemaNames() []string {
|
||||
return []string{
|
||||
OutputSchemaMinimal,
|
||||
OutputSchemaIntermediate,
|
||||
OutputSchemaFull,
|
||||
}
|
||||
}
|
||||
|
||||
// ValidateTranscript validates a full transcript against the public JSON
|
||||
// schema and seriatim-specific semantic rules.
|
||||
func ValidateTranscript(transcript Transcript) error {
|
||||
|
||||
@@ -5,6 +5,43 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestValidOutputSchemaName(t *testing.T) {
|
||||
valid := []string{
|
||||
OutputSchemaMinimal,
|
||||
OutputSchemaIntermediate,
|
||||
OutputSchemaFull,
|
||||
}
|
||||
for _, name := range valid {
|
||||
if !ValidOutputSchemaName(name) {
|
||||
t.Fatalf("expected %q to be valid", name)
|
||||
}
|
||||
}
|
||||
|
||||
invalid := []string{"", "compact", "minimal", "seriatim"}
|
||||
for _, name := range invalid {
|
||||
if ValidOutputSchemaName(name) {
|
||||
t.Fatalf("expected %q to be invalid", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOutputSchemaNames(t *testing.T) {
|
||||
names := OutputSchemaNames()
|
||||
want := []string{
|
||||
OutputSchemaMinimal,
|
||||
OutputSchemaIntermediate,
|
||||
OutputSchemaFull,
|
||||
}
|
||||
if len(names) != len(want) {
|
||||
t.Fatalf("len(names) = %d, want %d", len(names), len(want))
|
||||
}
|
||||
for index := range want {
|
||||
if names[index] != want[index] {
|
||||
t.Fatalf("names[%d] = %q, want %q", index, names[index], want[index])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateTranscriptAcceptsValidTranscript(t *testing.T) {
|
||||
transcript := validTranscript()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user