From 0ac3cc76b4b6c824c4b3f7a357d40b487984abfb Mon Sep 17 00:00:00 2001
From: xengineering <me@xengineering.eu>
Date: Thu, 9 May 2024 22:33:42 +0200
Subject: Inject examples only with new --example flag

The default use case should be to not inject example recipes.
---
 model/database.go     | 7 +++++--
 model/recipes_test.go | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

(limited to 'model')

diff --git a/model/database.go b/model/database.go
index 85d2662..f5fd67a 100644
--- a/model/database.go
+++ b/model/database.go
@@ -149,8 +149,8 @@ func MigrateDatabase(execVersion string) {
 	}
 }
 
-func InjectTestRecipes() {
-	Transaction(func(tx *sql.Tx) error {
+func InjectExampleRecipes() {
+	err := Transaction(func(tx *sql.Tx) error {
 		recipes := RecipeTestData()
 
 		for _, recipe := range recipes {
@@ -162,6 +162,9 @@ func InjectTestRecipes() {
 
 		return nil
 	})
+	if err != nil {
+		log.Fatalf("Failed to inject example recipes: %v", err)
+	}
 }
 
 func DisconnectDatabase() {
diff --git a/model/recipes_test.go b/model/recipes_test.go
index 159422f..13a8b2f 100644
--- a/model/recipes_test.go
+++ b/model/recipes_test.go
@@ -22,7 +22,7 @@ func TestRecipesRead(t *testing.T) {
 	defer DisconnectDatabase()
 	MigrateDatabase("dummy_version")
 
-	InjectTestRecipes()
+	InjectExampleRecipes()
 
 	r := make(Recipes, 0)
 
-- 
cgit v1.2.3-70-g09d2