Working on test
This commit is contained in:
parent
d9521fc59b
commit
05921335f6
@ -1,2 +1,9 @@
|
||||
# Allowance Planner 2000
|
||||
An improved Allowance Planner app.
|
||||
|
||||
## Running backend
|
||||
In order to run the backend, go to the `backend directory and run:
|
||||
|
||||
```bash
|
||||
$ go run .
|
||||
```
|
||||
|
@ -520,6 +520,40 @@ func TestPutAllowanceById(t *testing.T) {
|
||||
result.Value("weight").IsEqual(15)
|
||||
}
|
||||
|
||||
func TestCompleteTask(t *testing.T) {
|
||||
e := startServer(t)
|
||||
createTestTask(e)
|
||||
|
||||
// Create a task
|
||||
requestBody := map[string]interface{}{
|
||||
"name": "Test Task",
|
||||
"reward": 100,
|
||||
}
|
||||
e.POST("/tasks").WithJSON(requestBody).Expect().Status(201)
|
||||
|
||||
// Create two allowance goals
|
||||
e.POST("/user/1/allowance").WithJSON(CreateAllowanceRequest{
|
||||
Name: "Test Allowance 1",
|
||||
Target: 1000,
|
||||
Weight: 50,
|
||||
}).Expect().Status(200)
|
||||
e.POST("/user/1/allowance").WithJSON(CreateAllowanceRequest{
|
||||
Name: "Test Allowance 1",
|
||||
Target: 1000,
|
||||
Weight: 25,
|
||||
}).Expect().Status(200)
|
||||
e.PUT("/user/1/allowance/0").WithJSON(UpdateAllowanceRequest{
|
||||
Weight: 25,
|
||||
})
|
||||
|
||||
// Complete the task
|
||||
e.POST("/task/1/complete").Expect().Status(200)
|
||||
|
||||
// Verify the task is marked as completed
|
||||
result := e.GET("/task/1").Expect().Status(200).JSON().Object()
|
||||
result.Value("completed").Boolean().IsTrue()
|
||||
}
|
||||
|
||||
func getDelta(base time.Time, delta float64) (time.Time, time.Time) {
|
||||
start := base.Add(-time.Duration(delta) * time.Second)
|
||||
end := base.Add(time.Duration(delta) * time.Second)
|
||||
|
Loading…
x
Reference in New Issue
Block a user