LaunchCodeLiftoffProjects / LaunchCodeLiftoffProjects/Collab-Blog

Writing a test for the /blog/update endpoint

オープン
#29 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

JUnit
主要言語
TypeScript
スター
8
フォーク
20
PR マージ指標
30日以内にマージされた PR はありません

説明

**Is your feature request related to a problem? Please describe.**
The /blog/update endpoint is in need of a unit test.

**Describe the solution you'd like**
Write a test that successfully updates already existing information inside of the database to something new.

**Additional context**
This is a test written inside of BlogTests.Java to test the @PostMapping /blogs endpoint.

```
@Test
public void postBlogs_SavesBlogToDatabase() throws Exception {
blogTestsUtil.tearDown();
Blog blog1 = new Blog("Our Very First Blog Post", "This is an actual Subheader", "An Actual Image", "This body has things we actually care about");
MockMultipartFile firstFile = new MockMultipartFile("image", "filename.txt", "text/plain", "some xml".getBytes());
MvcResult result = mockMvc.perform(multipart("/blogs").file(firstFile).param("blogData", objectMapper.writeValueAsString(blog1)))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.header").value("Our Very First Blog Post"))
.andReturn();
assertEquals(1, blogRepository.findAll().size());
blogTestsUtil.tearDown();
}
```

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

BlogTests.Java と既存の postBlogs_SavesBlogToDatabase テストから始めて、テストのセットアップとデータベースのクリーンアップを理解します。想定されている対象が /blog/update なのか、コンテキストに示されている /blogs エンドポイントなのかを確認し、その後、既存のデータベース情報の更新を対象にし、更新後の結果と永続性を検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, spring
領域
backend, database, testing
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。