unit-test-tutorial

概要

このプロジェクトはアニメのデータの登録、検索、更新、削除をするレポジトリです。

前提

  • Java 17
  • Spring Boot 2.7.1
  • Docker 20.10.13

起動手順

$ git clone https://github.com/reytech-co-jp/unit-test-tutorial.git

$ cd unit-test-tutorial

$ docker-compose up -d

$ ./gradlew bootRun

起動成功時のイメージ image

使用方法

Postmanを使用した画面とcurlコマンドを記載

全件検索

curl 'http://localhost:8080/api/anime'

image

一件検索

curl 'http://localhost:8080/api/anime/1'

image

登録

curl -X POST 'http://localhost:8080/api/anime' \
-H "Content-Type: application/json" \
-d '{
"name": "Dr.STONE",
"genre": "survival"
}'

※GitBashの場合、日本語の入力は不可

image

更新

curl -X PATCH 'http://localhost:8080/api/anime/1' \
-H "Content-Type: application/json" \
-d '{
"name": "Fruits Basket",
"genre": "Romantic Comedy"
}'

※GitBashの場合、日本語の入力は不可

image

削除

curl -X DELETE 'http://localhost:8080/api/anime/1'

image

バリデーションエラー

image

更新及び削除で指定したIDのデータが存在しない時

image

終了手順

./gradlew bootRunコマンドで実行している場合)ctrl + cで終了する

$ docker-compose down

ケアできていないエラー

  • 存在しないURLへのアクセス
  • DBへの接続できないなどのシステムエラー