Do not extract test url
This commit is contained in:
parent
5f4abb3387
commit
a0f0a245c2
@ -9,7 +9,6 @@ import (
|
||||
|
||||
const (
|
||||
TestGoalName = "Test Goal"
|
||||
UserGoalsURL = "/user/1/goals"
|
||||
)
|
||||
|
||||
func startServer(t *testing.T) *httpexpect.Expect {
|
||||
@ -50,7 +49,7 @@ func TestGetUserBadId(t *testing.T) {
|
||||
|
||||
func TestGetUserGoalsWhenNoGoalsPresent(t *testing.T) {
|
||||
e := startServer(t)
|
||||
result := e.GET(UserGoalsURL).Expect().Status(200).JSON().Array()
|
||||
result := e.GET("/user/1/goals").Expect().Status(200).JSON().Array()
|
||||
result.Length().IsEqual(0)
|
||||
}
|
||||
|
||||
@ -74,7 +73,7 @@ func TestCreateUserGoal(t *testing.T) {
|
||||
"weight": 10,
|
||||
}
|
||||
|
||||
response := e.POST(UserGoalsURL).
|
||||
response := e.POST("/user/1/goals").
|
||||
WithJSON(requestBody).
|
||||
Expect().
|
||||
Status(201).
|
||||
@ -85,7 +84,7 @@ func TestCreateUserGoal(t *testing.T) {
|
||||
goalId := response.Value("id").Number().Raw()
|
||||
|
||||
// Verify the goal exists in the list of goals
|
||||
goals := e.GET(UserGoalsURL).
|
||||
goals := e.GET("/user/1/goals").
|
||||
Expect().
|
||||
Status(200).
|
||||
JSON().Array()
|
||||
@ -125,7 +124,7 @@ func TestCreateUserGoalInvalidInput(t *testing.T) {
|
||||
"weight": 10,
|
||||
}
|
||||
|
||||
e.POST(UserGoalsURL).
|
||||
e.POST("/user/1/goals").
|
||||
WithJSON(requestBody).
|
||||
Expect().
|
||||
Status(400)
|
||||
@ -135,7 +134,7 @@ func TestCreateUserGoalInvalidInput(t *testing.T) {
|
||||
"target": 5000,
|
||||
}
|
||||
|
||||
e.POST(UserGoalsURL).
|
||||
e.POST("/user/1/goals").
|
||||
WithJSON(invalidRequest).
|
||||
Expect().
|
||||
Status(400)
|
||||
@ -165,7 +164,7 @@ func TestDeleteUserGoal(t *testing.T) {
|
||||
"target": 1000,
|
||||
"weight": 5,
|
||||
}
|
||||
response := e.POST(UserGoalsURL).
|
||||
response := e.POST("/user/1/goals").
|
||||
WithJSON(createRequest).
|
||||
Expect().
|
||||
Status(201).
|
||||
@ -180,7 +179,7 @@ func TestDeleteUserGoal(t *testing.T) {
|
||||
JSON().Object().Value("message").IsEqual("Goal deleted successfully")
|
||||
|
||||
// Verify the goal no longer exists
|
||||
goals := e.GET(UserGoalsURL).
|
||||
goals := e.GET("/user/1/goals").
|
||||
Expect().
|
||||
Status(200).
|
||||
JSON().Array()
|
||||
|
Loading…
x
Reference in New Issue
Block a user