Skip to content

Commit

Permalink
draft-api: Stop ignoring error in ArticleApiClient
Browse files Browse the repository at this point in the history
  • Loading branch information
jnatten committed Sep 1, 2023
1 parent 64adeee commit cf0c491
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ trait ArticleApiClient {
): Try[Draft] = {
converterService
.toArticleApiArticle(draft)
.map(article =>
.flatMap(article =>
postWithData[common.article.Article, common.article.Article](
s"$InternalEndpoint/article/$id",
article,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,20 @@ class ArticleApiClientTest
.flatMap(article => articleApiCient.validateArticle(article, importValidate = false, None))
result.isSuccess should be(false)
}

test("that updating an article returns 400 if missing required field") {
AuthUser.setHeader(s"Bearer $exampleToken")
val articleApiCient = new ArticleApiClient(articleApiBaseUrl)
val invalidArticle = testArticle.copy(metaDescription = Seq.empty)
val result = articleApiCient.updateArticle(
id = 10,
draft = invalidArticle,
externalIds = List.empty,
useImportValidation = false,
useSoftValidation = false,
user = authUser
)

result.isSuccess should be(false)
}
}

0 comments on commit cf0c491

Please sign in to comment.