From a0f0a245c2333d56c0a21cabf621d1055a757c3f Mon Sep 17 00:00:00 2001 From: Sebastiaan de Schaetzen Date: Thu, 8 May 2025 15:45:43 +0200 Subject: [PATCH] Do not extract test url --- backend/api_test.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/backend/api_test.go b/backend/api_test.go index 5884042..2c4b50e 100644 --- a/backend/api_test.go +++ b/backend/api_test.go @@ -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()