refac: missing user or article is reported with a domain not-found error instead of a raw GORM error, and the API answers 404 for it

This commit is contained in:
fsylvain committed 2026-09-23 18:55:05 +02:00
1 parent 7c57173497
commit 8460a078e3
13 files changed
+426 -32

No files matched your search

+6 -6
View File
@@ -40,10 +40,10 @@ Feature: Use case baseline characterization
| method | id | outcome |
| GetArticle | 1 | the article with id 1 |
| GetArticle | 2 | the article with id 2 (GetArticle does not hide offline articles) |
| GetArticle | 9 | the repository's not-found error (gorm.ErrRecordNotFound) |
| GetArticle | 9 | the error article.ErrArticleNotFound |
| GetOnlineArticle | 1 | the article with id 1 |
| GetOnlineArticle | 2 | the error article.ErrArticleNotFound |
| GetOnlineArticle | 9 | the repository's not-found error (gorm.ErrRecordNotFound), not article.ErrArticleNotFound |
| GetOnlineArticle | 9 | the error article.ErrArticleNotFound |
Scenario Outline: GetArticleByName delegates verbatim to the repository
Given an article repository fake containing an article titled "Backyard Renovation Update" with id 1
@@ -53,7 +53,7 @@ Feature: Use case baseline characterization
Examples:
| name | outcome |
| Backyard Renovation Update | the article with id 1 |
| Unknown Title | the repository's not-found error (gorm.ErrRecordNotFound) |
| Unknown Title | the error article.ErrArticleNotFound |
Scenario Outline: ListArticles filters by is_online
Given an article repository fake containing:
@@ -150,11 +150,11 @@ Feature: Use case baseline characterization
Examples:
| method | input | outcome |
| GetUser | 1 | the user with id 1 |
| GetUser | 9 | the repository's not-found error (gorm.ErrRecordNotFound) |
| GetUser | 9 | the error user.ErrUserNotFound |
| GetUserByUsername | alice | the user with id 1 |
| GetUserByUsername | bob | the repository's not-found error (gorm.ErrRecordNotFound) |
| GetUserByUsername | bob | the error user.ErrUserNotFound |
| GetUserByEmail | alice@example.com | the user with id 1 |
| GetUserByEmail | bob@example.com | the repository's not-found error (gorm.ErrRecordNotFound) |
| GetUserByEmail | bob@example.com | the error user.ErrUserNotFound |
Scenario: ListUsers returns every user in the fake
Given a user repository fake containing users with ids 1 and 2