Skip to content

Commit b9571c0

Browse files
committed
[handlers] more tests for base handler
1 parent 4c81742 commit b9571c0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

internal/sms-gateway/handlers/base/handler_test.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ func TestHandler_BodyParserValidator(t *testing.T) {
123123
req = httptest.NewRequest("POST", test.path, nil)
124124
}
125125

126-
resp, _ := app.Test(req)
126+
resp, err := app.Test(req)
127+
if err != nil {
128+
t.Fatalf("app.Test failed: %v", err)
129+
}
127130
if test.expectedStatus != resp.StatusCode {
128131
t.Errorf("Expected status code %d, got %d", test.expectedStatus, resp.StatusCode)
129132
}
@@ -151,6 +154,11 @@ func TestHandler_QueryParserValidator(t *testing.T) {
151154
path string
152155
expectedStatus int
153156
}{
157+
{
158+
description: "Invalid query parameters - non-integer age",
159+
path: "/test?name=John&age=abc",
160+
expectedStatus: fiber.StatusBadRequest,
161+
},
154162
{
155163
description: "Valid query parameters",
156164
path: "/test?name=John&age=25",
@@ -177,7 +185,10 @@ func TestHandler_QueryParserValidator(t *testing.T) {
177185
t.Run(test.description, func(t *testing.T) {
178186
req := httptest.NewRequest("GET", test.path, nil)
179187

180-
resp, _ := app.Test(req)
188+
resp, err := app.Test(req)
189+
if err != nil {
190+
t.Fatalf("app.Test failed: %v", err)
191+
}
181192
if test.expectedStatus != resp.StatusCode {
182193
t.Errorf("Expected status code %d, got %d", test.expectedStatus, resp.StatusCode)
183194
}
@@ -231,7 +242,10 @@ func TestHandler_ParamsParserValidator(t *testing.T) {
231242
t.Run(test.description, func(t *testing.T) {
232243
req := httptest.NewRequest("GET", test.path, nil)
233244

234-
resp, _ := app.Test(req)
245+
resp, err := app.Test(req)
246+
if err != nil {
247+
t.Fatalf("app.Test failed: %v", err)
248+
}
235249
if test.expectedStatus != resp.StatusCode {
236250
t.Errorf("Expected status code %d, got %d", test.expectedStatus, resp.StatusCode)
237251
}

0 commit comments

Comments
 (0)