summaryrefslogtreecommitdiff
path: root/model/recipe_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/recipe_test.go')
-rw-r--r--model/recipe_test.go28
1 files changed, 24 insertions, 4 deletions
diff --git a/model/recipe_test.go b/model/recipe_test.go
index 1119d20..6bc7b54 100644
--- a/model/recipe_test.go
+++ b/model/recipe_test.go
@@ -20,11 +20,28 @@ func TestRecipeCrud(t *testing.T) {
storage := NewStorage(storagePath)
- ConnectDatabase(filepath.Join(storage.Path, "ceres.sqlite3"))
- defer DisconnectDatabase()
- MigrateDatabase("dummy_version")
+ database, err := OpenDB(filepath.Join(storage.Path, "ceres.sqlite3"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer func() {
+ err := database.Close()
+ if err != nil {
+ t.Fatal(err)
+ }
+ }()
+
+ err = database.Migrate()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ err = database.CreateExamples()
+ if err != nil {
+ t.Fatal(err)
+ }
- Transaction(func(tx *sql.Tx) error {
+ err = database.Transaction(func(tx *sql.Tx) error {
var original, readback, update, updated, deleted Recipe
recipes := RecipeTestData()
@@ -82,4 +99,7 @@ func TestRecipeCrud(t *testing.T) {
return nil
})
+ if err != nil {
+ t.Fatalf("Failed to read recipes from database: %s", err)
+ }
}