Rename from allowance to history
This commit is contained in:
parent
9729ac58ac
commit
9b4e217fcf
@ -406,14 +406,14 @@ func TestPostAllowanceInvalidUserId(t *testing.T) {
|
|||||||
Status(404)
|
Status(404)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetAllowance(t *testing.T) {
|
func TestGetHistory(t *testing.T) {
|
||||||
e := startServer(t)
|
e := startServer(t)
|
||||||
|
|
||||||
e.POST("/user/1/allowance").WithJSON(PostAllowance{Allowance: 100}).Expect().Status(200)
|
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: 20}).Expect().Status(200)
|
||||||
e.POST("/user/1/allowance").WithJSON(PostAllowance{Allowance: -10}).Expect().Status(200)
|
e.POST("/user/1/allowance").WithJSON(PostAllowance{Allowance: -10}).Expect().Status(200)
|
||||||
|
|
||||||
response := e.GET("/user/1/allowance").Expect().Status(200).JSON().Array()
|
response := e.GET("/user/1/history").Expect().Status(200).JSON().Array()
|
||||||
response.Length().IsEqual(3)
|
response.Length().IsEqual(3)
|
||||||
response.Value(0).Object().Value("allowance").Number().IsEqual(100)
|
response.Value(0).Object().Value("allowance").Number().IsEqual(100)
|
||||||
response.Value(0).Object().Value("timestamp").String().AsDateTime().InRange(getDelta(time.Now(), 2.0))
|
response.Value(0).Object().Value("timestamp").String().AsDateTime().InRange(getDelta(time.Now(), 2.0))
|
||||||
|
@ -325,7 +325,7 @@ func postAllowance(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, gin.H{"message": "Allowance updated successfully"})
|
c.JSON(http.StatusOK, gin.H{"message": "Allowance updated successfully"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAllowance(c *gin.Context) {
|
func getHistory(c *gin.Context) {
|
||||||
userIdStr := c.Param("userId")
|
userIdStr := c.Param("userId")
|
||||||
userId, err := strconv.Atoi(userIdStr)
|
userId, err := strconv.Atoi(userIdStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -356,7 +356,7 @@ func start(ctx context.Context, config *ServerConfig) {
|
|||||||
router.GET("/api/users", getUsers)
|
router.GET("/api/users", getUsers)
|
||||||
router.GET("/api/user/:userId", getUser)
|
router.GET("/api/user/:userId", getUser)
|
||||||
router.POST("/api/user/:userId/allowance", postAllowance)
|
router.POST("/api/user/:userId/allowance", postAllowance)
|
||||||
router.GET("/api/user/:userId/allowance", getAllowance)
|
router.GET("/api/user/:userId/history", getHistory)
|
||||||
router.GET("/api/user/:userId/goals", getUserGoals)
|
router.GET("/api/user/:userId/goals", getUserGoals)
|
||||||
router.POST("/api/user/:userId/goals", createUserGoal)
|
router.POST("/api/user/:userId/goals", createUserGoal)
|
||||||
router.DELETE("/api/user/:userId/goal/:goalId", deleteUserGoal)
|
router.DELETE("/api/user/:userId/goal/:goalId", deleteUserGoal)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user