diff options
author | xengineering <me@xengineering.eu> | 2024-03-04 20:39:17 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-03-04 20:45:11 +0100 |
commit | 74fc87dcfaa8a65c14c0ef6fe88b6df02f2e90cb (patch) | |
tree | 5d49a81d5da76d4b632d16f9da746f172f736139 /model/recipe_test.go | |
parent | b62c686702622b747ab082b7b12b3e611e1d7e1f (diff) | |
download | ceres-74fc87dcfaa8a65c14c0ef6fe88b6df02f2e90cb.tar ceres-74fc87dcfaa8a65c14c0ef6fe88b6df02f2e90cb.tar.zst ceres-74fc87dcfaa8a65c14c0ef6fe88b6df02f2e90cb.zip |
model: Implement Stringer interface for Recipe
This allows to print a recipe with a fmt.Printf() call more easily:
fmt.Printf("%s\n", recipe)
This is also used for better error output in unit tests with t.Fatalf().
The Stringer interface is implemented with the JSON package because an
indented version of a recipe is a useful string representation.
Diffstat (limited to 'model/recipe_test.go')
-rw-r--r-- | model/recipe_test.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/model/recipe_test.go b/model/recipe_test.go index 0057a3d..55041a6 100644 --- a/model/recipe_test.go +++ b/model/recipe_test.go @@ -30,7 +30,8 @@ func TestRecipeCrud(t *testing.T) { } if !reflect.DeepEqual(original, readback) { - t.Fatalf("Recipes did not match after create / read cycle") + t.Fatalf("Recipes did not match after create / read cycle:\n"+ + "Before: %s\nAfter: %s\n", original, readback) } update.Id = original.Id @@ -46,8 +47,9 @@ func TestRecipeCrud(t *testing.T) { t.Fatalf("Failed to read back updated recipe: %v\n", err) } - if !reflect.DeepEqual(updated, update) { - t.Fatalf("Recipes did not match after update / read cycle") + if !reflect.DeepEqual(update, updated) { + t.Fatalf("Recipes did not match after update / read cycle:\n"+ + "Update: %s\nUpdated: %s\n", update, updated) } if reflect.DeepEqual(updated, original) { |