diff options
author | xengineering <me@xengineering.eu> | 2024-03-03 20:06:40 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-03-04 20:33:58 +0100 |
commit | b62c686702622b747ab082b7b12b3e611e1d7e1f (patch) | |
tree | aa0f31ad0381dbeb3247870744d07bc9c81ed31b /model/database.go | |
parent | 4dcd846aa7c8d15c96ba13380f48b985fb2c992e (diff) | |
download | ceres-b62c686702622b747ab082b7b12b3e611e1d7e1f.tar ceres-b62c686702622b747ab082b7b12b3e611e1d7e1f.tar.zst ceres-b62c686702622b747ab082b7b12b3e611e1d7e1f.zip |
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.
Diffstat (limited to 'model/database.go')
-rw-r--r-- | model/database.go | 24 |
1 files changed, 15 insertions, 9 deletions
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() } } |