refac: deleting an article also deletes its images, and deleting a missing article returns 404
This commit is contained in:
1 parent
c16fdbd26d
commit
8a8a24434a
13 files changed
+414
-18
No files matched your search
@@ -321,7 +321,7 @@ func TestDeleteArticleReportsMissingArticle(t *testing.T) {
|
||||
t.Run("id_1", func(t *testing.T) {
|
||||
repo := newMockArticleRepo()
|
||||
repo.articles[1] = article.Article{ID: 1}
|
||||
uc := useCases.NewDeleteArticleUseCase(repo)
|
||||
uc := useCases.NewDeleteArticleUseCase(repo, newMockImageRepo())
|
||||
|
||||
err := uc.DeleteArticle(1)
|
||||
if err != nil {
|
||||
@@ -332,7 +332,7 @@ func TestDeleteArticleReportsMissingArticle(t *testing.T) {
|
||||
t.Run("id_9", func(t *testing.T) {
|
||||
repo := newMockArticleRepo()
|
||||
repo.articles[1] = article.Article{ID: 1}
|
||||
uc := useCases.NewDeleteArticleUseCase(repo)
|
||||
uc := useCases.NewDeleteArticleUseCase(repo, newMockImageRepo())
|
||||
|
||||
err := uc.DeleteArticle(9)
|
||||
if !errors.Is(err, article.ErrArticleNotFound) {
|
||||
@@ -345,7 +345,7 @@ func TestDeleteArticlePropagatesRepositoryFailure(t *testing.T) {
|
||||
repo := newMockArticleRepo()
|
||||
repo.articles[1] = article.Article{ID: 1}
|
||||
repo.fail.failNext("Delete")
|
||||
uc := useCases.NewDeleteArticleUseCase(repo)
|
||||
uc := useCases.NewDeleteArticleUseCase(repo, newMockImageRepo())
|
||||
|
||||
err := uc.DeleteArticle(1)
|
||||
if !errors.Is(err, errRepositoryFailure) {
|
||||
|
||||
Reference in new issue
Block a user