feat: some more tests
This commit is contained in:
@@ -38,3 +38,32 @@ func TestParseRecipe_Golden(t *testing.T) {
|
||||
t.Fatalf("JSON mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseRecipe_NoDescription(t *testing.T) {
|
||||
td := filepath.Join("testdata", "recipe_no_description")
|
||||
input := filepath.Join(td, "input.md")
|
||||
output := filepath.Join(td, "output.json")
|
||||
|
||||
inputContent, err := os.ReadFile(input)
|
||||
if err != nil {
|
||||
t.Fatalf("read input.md: %v", err)
|
||||
}
|
||||
|
||||
got, err := parser.ParseFile(string(inputContent))
|
||||
if err != nil {
|
||||
t.Fatalf("ParseFile: %v", err)
|
||||
}
|
||||
|
||||
var want map[string]any
|
||||
b, err := os.ReadFile(output)
|
||||
if err != nil {
|
||||
t.Fatalf("read expected.json: %v", err)
|
||||
}
|
||||
if err := json.Unmarshal(b, &want); err != nil {
|
||||
t.Fatalf("unmarshal expected.json: %v", err)
|
||||
}
|
||||
|
||||
if diff := cmp.Diff(want, got); diff != "" {
|
||||
t.Fatalf("JSON mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user