diff --git a/app/interfaces/controller/auth_test.go b/app/interfaces/controller/auth_test.go deleted file mode 100644 index e4b50b8..0000000 --- a/app/interfaces/controller/auth_test.go +++ /dev/null @@ -1,7 +0,0 @@ -package controller - -import "testing" - -func TestSignIn(t *testing.T) { - // TODO: controller tests with mocks. -} diff --git a/app/interfaces/repository/category.go b/app/interfaces/repository/category.go index d9000a1..8e3c6e8 100644 --- a/app/interfaces/repository/category.go +++ b/app/interfaces/repository/category.go @@ -190,6 +190,7 @@ func (cr *Category) Save(req request.StoreCategory) (int, error) { (?, ?, ?) `, req.Name, now, now) if err != nil { + _ = tx.Rollback() return 0, err } @@ -253,6 +254,7 @@ func (cr *Category) DeleteByID(id int) (int, error) { var count int err = row.Scan(&count) if err != nil { + _ = tx.Rollback() return 0, nil } diff --git a/app/interfaces/repository/comment.go b/app/interfaces/repository/comment.go index adfb6f0..2b2bbbb 100644 --- a/app/interfaces/repository/comment.go +++ b/app/interfaces/repository/comment.go @@ -145,6 +145,7 @@ func (cr *Comment) FindByID(id int) (domain.Comment, error) { func (cr *Comment) Save(req request.StoreComment) (int, error) { tx, err := cr.ConnMySQL.Begin() if err != nil { + _ = tx.Rollback() return 0, err } @@ -178,6 +179,7 @@ func (cr *Comment) Save(req request.StoreComment) (int, error) { func (cr *Comment) SaveStatusByID(req request.UpdateCommentStatus) error { tx, err := cr.ConnMySQL.Begin() if err != nil { + _ = tx.Rollback() return err } diff --git a/app/interfaces/repository/post.go b/app/interfaces/repository/post.go index 2865b7b..e638a93 100644 --- a/app/interfaces/repository/post.go +++ b/app/interfaces/repository/post.go @@ -1706,6 +1706,7 @@ func (pr *Post) FindByID(id int) (domain.Post, error) { func (pr *Post) Save(req request.StorePost) (int, error) { tx, err := pr.ConnMySQL.Begin() if err != nil { + _ = tx.Rollback() return 0, err } @@ -1750,6 +1751,7 @@ func (pr *Post) Save(req request.StorePost) (int, error) { _, err = tx.Exec(stmt, vArgs...) if err != nil { + _ = tx.Rollback() return 0, err } @@ -1764,6 +1766,7 @@ func (pr *Post) Save(req request.StorePost) (int, error) { func (pr *Post) SaveByID(req request.UpdatePost) error { tx, err := pr.ConnMySQL.Begin() if err != nil { + _ = tx.Rollback() return err } @@ -1816,6 +1819,7 @@ func (pr *Post) SaveByID(req request.UpdatePost) error { _, err = tx.Exec(stmt, vArgs...) if err != nil { + _ = tx.Rollback() return err } @@ -1840,12 +1844,14 @@ func (pr *Post) DeleteByID(id int) (int, error) { `, id) if err != nil { + _ = tx.Rollback() return 0, err } var count int err = row.Scan(&count) if err != nil { + _ = tx.Rollback() return 0, err } diff --git a/app/interfaces/repository/tag.go b/app/interfaces/repository/tag.go index 2595bbf..e1a7633 100644 --- a/app/interfaces/repository/tag.go +++ b/app/interfaces/repository/tag.go @@ -178,6 +178,7 @@ func (tr *Tag) FindByName(name string) (domain.Tag, error) { func (tr *Tag) Save(req request.StoreTag) (int, error) { tx, err := tr.ConnMySQL.Begin() if err != nil { + _ = tx.Rollback() return 0, err } @@ -211,6 +212,7 @@ func (tr *Tag) Save(req request.StoreTag) (int, error) { func (tr *Tag) SaveByID(req request.UpdateTag) error { tx, err := tr.ConnMySQL.Begin() if err != nil { + _ = tx.Rollback() return err } @@ -249,6 +251,7 @@ func (tr *Tag) DeleteByID(id int) (int, error) { `, id) if err != nil { + _ = tx.Rollback() return 0, err }