39 lines
1014 B
Go
39 lines
1014 B
Go
package registry_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.max-richter.dev/max/marka/registry"
|
|
)
|
|
|
|
func TestValidateRecipe_InvalidType(t *testing.T) {
|
|
recipe := map[string]any{
|
|
"@type": "Recipe",
|
|
"recipeYield": 4,
|
|
"recipeIngredient": []string{
|
|
"500 g flour",
|
|
"300 ml water",
|
|
},
|
|
"recipeInstructions": "Mix and bake.",
|
|
}
|
|
|
|
if err := registry.ValidateSchema(recipe, "schema:Recipe"); err == nil {
|
|
t.Fatalf("expected validation error for invalid recipe, got nil")
|
|
}
|
|
}
|
|
|
|
func TestValidateRecipe_Valid(t *testing.T) {
|
|
recipe := map[string]any{
|
|
"@type": "Recipe",
|
|
"name": "Simple Bread",
|
|
"cookTime": "PT30M",
|
|
"recipeIngredient": []any{"500 g flour", "300 ml water", "10 g salt", "3 g yeast"},
|
|
"recipeInstructions": "Mix ingredients, let dough rise, bake at 220°C for 35 minutes.",
|
|
"recipeYield": "1 loaf",
|
|
}
|
|
|
|
if err := registry.ValidateSchema(recipe, "schema:Recipe"); err != nil {
|
|
t.Fatalf("expected valid recipe, got error: %v", err)
|
|
}
|
|
}
|