Add D&D spells response schema
This commit is contained in:
48
internal/modules/extract/dnd/spells/schema_test.go
Normal file
48
internal/modules/extract/dnd/spells/schema_test.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package spells
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||
)
|
||||
|
||||
func TestLookupResponseSchemaForSpells(t *testing.T) {
|
||||
schema, ok := llm.LookupResponseSchema(llm.DNDSpellsSchemaKey)
|
||||
if !ok {
|
||||
t.Fatalf("LookupResponseSchema(%q) ok = false, want true", llm.DNDSpellsSchemaKey)
|
||||
}
|
||||
if schema.ID != "notarius.dnd.spells" {
|
||||
t.Fatalf("schema.ID = %q, want notarius.dnd.spells", schema.ID)
|
||||
}
|
||||
if schema.Version != SchemaVersion {
|
||||
t.Fatalf("schema.Version = %q, want %q", schema.Version, SchemaVersion)
|
||||
}
|
||||
if schema.Name != "notarius_dnd_spells_v1" {
|
||||
t.Fatalf("schema.Name = %q, want notarius_dnd_spells_v1", schema.Name)
|
||||
}
|
||||
if !strings.HasPrefix(schema.SHA256, "sha256:") {
|
||||
t.Fatalf("schema.SHA256 = %q, want sha256 prefix", schema.SHA256)
|
||||
}
|
||||
if !json.Valid(schema.JSONSchema) {
|
||||
t.Fatalf("schema.JSONSchema is invalid JSON: %s", schema.JSONSchema)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResponseSchemaDiagnosticsOmitRawSchema(t *testing.T) {
|
||||
schema := llm.MustLookupResponseSchema(llm.DNDSpellsSchemaKey)
|
||||
diagnostics := schema.DiagnosticsMap()
|
||||
|
||||
if diagnostics["key"] != llm.DNDSpellsSchemaKey {
|
||||
t.Fatalf("diagnostics[key] = %#v, want %q", diagnostics["key"], llm.DNDSpellsSchemaKey)
|
||||
}
|
||||
for _, key := range []string{"id", "version", "name", "sha256"} {
|
||||
if diagnostics[key] == "" {
|
||||
t.Fatalf("diagnostics[%q] = %#v, want value", key, diagnostics[key])
|
||||
}
|
||||
}
|
||||
if _, ok := diagnostics["json_schema"]; ok {
|
||||
t.Fatalf("diagnostics should omit raw schema content: %#v", diagnostics)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user