Merge branch 'main' into AP-63
All checks were successful
Backend Build and Test / build (push) Successful in 3m1s
All checks were successful
Backend Build and Test / build (push) Successful in 3m1s
This commit is contained in:
commit
f53a2ea590
BIN
backend/allowance_planner.db3.backup.1
Normal file
BIN
backend/allowance_planner.db3.backup.1
Normal file
Binary file not shown.
@ -605,6 +605,36 @@ func TestCompleteTask(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCompleteTaskWithNoWeights(t *testing.T) {
|
||||||
|
e := startServer(t)
|
||||||
|
taskId := createTestTaskWithAmount(e, 101)
|
||||||
|
|
||||||
|
e.GET("/tasks").Expect().Status(200).JSON().Array().Length().IsEqual(1)
|
||||||
|
|
||||||
|
// Ensure main allowance has no weight
|
||||||
|
e.PUT("/user/1/allowance/0").WithJSON(UpdateAllowanceRequest{
|
||||||
|
Weight: 0,
|
||||||
|
}).Expect().Status(200)
|
||||||
|
|
||||||
|
// Complete the task
|
||||||
|
e.POST("/task/" + strconv.Itoa(taskId) + "/complete").Expect().Status(200)
|
||||||
|
|
||||||
|
// Verify the task is marked as completed
|
||||||
|
e.GET("/task/" + strconv.Itoa(taskId)).Expect().Status(404)
|
||||||
|
|
||||||
|
// Verify the allowances are updated for user 1
|
||||||
|
allowances := e.GET("/user/1/allowance").Expect().Status(200).JSON().Array()
|
||||||
|
allowances.Length().IsEqual(1)
|
||||||
|
allowances.Value(0).Object().Value("id").Number().IsEqual(0)
|
||||||
|
allowances.Value(0).Object().Value("progress").Number().InDelta(101.00, 0.01)
|
||||||
|
|
||||||
|
// And also for user 2
|
||||||
|
allowances = e.GET("/user/2/allowance").Expect().Status(200).JSON().Array()
|
||||||
|
allowances.Length().IsEqual(1)
|
||||||
|
allowances.Value(0).Object().Value("id").Number().IsEqual(0)
|
||||||
|
allowances.Value(0).Object().Value("progress").Number().InDelta(101.00, 0.01)
|
||||||
|
}
|
||||||
|
|
||||||
func TestCompleteTaskAllowanceWeightsSumTo0(t *testing.T) {
|
func TestCompleteTaskAllowanceWeightsSumTo0(t *testing.T) {
|
||||||
e := startServer(t)
|
e := startServer(t)
|
||||||
taskId := createTestTaskWithAmount(e, 101)
|
taskId := createTestTaskWithAmount(e, 101)
|
||||||
@ -643,6 +673,11 @@ func TestCompleteAllowance(t *testing.T) {
|
|||||||
createTestTaskWithAmount(e, 100)
|
createTestTaskWithAmount(e, 100)
|
||||||
createTestAllowance(e, "Test Allowance 1", 100, 50)
|
createTestAllowance(e, "Test Allowance 1", 100, 50)
|
||||||
|
|
||||||
|
// Update base allowance
|
||||||
|
e.PUT("/user/1/allowance/0").WithJSON(UpdateAllowanceRequest{
|
||||||
|
Weight: 0,
|
||||||
|
}).Expect().Status(200)
|
||||||
|
|
||||||
// Complete the task
|
// Complete the task
|
||||||
e.POST("/task/1/complete").Expect().Status(200)
|
e.POST("/task/1/complete").Expect().Status(200)
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ create table users
|
|||||||
(
|
(
|
||||||
id integer primary key,
|
id integer primary key,
|
||||||
name text not null,
|
name text not null,
|
||||||
weight real not null default 0.0,
|
weight real not null default 10.0,
|
||||||
balance integer not null default 0
|
balance integer not null default 0
|
||||||
) strict;
|
) strict;
|
||||||
|
|
||||||
|
1
backend/migrations/3_change_weight_default.sql
Normal file
1
backend/migrations/3_change_weight_default.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
update users set weight = 10.0 where weight = 0.0;
|
Loading…
x
Reference in New Issue
Block a user