Add endpoint to create allowance (#34)

Closes #11

Reviewed-on: #34
This commit was merged in pull request #34.
This commit is contained in:
2025-05-13 13:52:10 +02:00
parent 44d85fc155
commit 62f43d7eb3
6 changed files with 81 additions and 4 deletions

View File

@@ -385,3 +385,22 @@ func TestPutTaskInvalidTaskId(t *testing.T) {
}
e.PUT("/task/999").WithJSON(requestBody).Expect().Status(404)
}
func TestPostAllowance(t *testing.T) {
e := startServer(t)
e.POST("/user/1/allowance").WithJSON(PostAllowance{Allowance: 100}).Expect().Status(200)
e.POST("/user/1/allowance").WithJSON(PostAllowance{Allowance: 20}).Expect().Status(200)
e.POST("/user/1/allowance").WithJSON(PostAllowance{Allowance: -10}).Expect().Status(200)
response := e.GET("/user/1").Expect().Status(200).JSON().Object()
response.Value("allowance").Number().IsEqual(100 + 20 - 10)
}
func TestPostAllowanceInvalidUserId(t *testing.T) {
e := startServer(t)
e.POST("/user/999/allowance").WithJSON(PostAllowance{Allowance: 100}).Expect().
Status(404)
}