feat: renderer
This commit is contained in:
38
validator/validator_test.go
Normal file
38
validator/validator_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package validator_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.max-richter.dev/max/marka/validator"
|
||||
)
|
||||
|
||||
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 := validator.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 := validator.ValidateSchema(recipe, "schema:Recipe"); err != nil {
|
||||
t.Fatalf("expected valid recipe, got error: %v", err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user