From b62c686702622b747ab082b7b12b3e611e1d7e1f Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 3 Mar 2024 20:06:40 +0100 Subject: model: Create test data with Go instead of SQL This allows to formulate the test data with an object-based model which is easier than writing it down in a relational model. --- model/database.go | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'model/database.go') diff --git a/model/database.go b/model/database.go index fac4d35..265b438 100644 --- a/model/database.go +++ b/model/database.go @@ -38,15 +38,21 @@ func InitDatabase() { log.Fatal(err) } - for _, v := range []string{`migrate`, `testdata`} { - query, err := GetSql(v) - if err != nil { - log.Fatal(err) - } - _, err = db.Exec(query) - if err != nil { - log.Fatal(err) - } + query, err := GetSql(`migrate`) + if err != nil { + log.Fatal(err) + } + _, err = db.Exec(query) + if err != nil { + log.Fatal(err) + } +} + +func InjectTestRecipes() { + recipes := RecipeTestData() + + for _, recipe := range recipes { + recipe.Create() } } -- cgit v1.2.3-70-g09d2