(t *testing.T)
| 178 | } |
| 179 | |
| 180 | func TestNewInternalServerError(t *testing.T) { |
| 181 | t.Parallel() |
| 182 | |
| 183 | scenarios := []struct { |
| 184 | message string |
| 185 | data any |
| 186 | expected string |
| 187 | }{ |
| 188 | {"", nil, `{"data":{},"message":"Something went wrong while processing your request.","status":500}`}, |
| 189 | {"demo", "rawData_test", `{"data":{},"message":"Demo.","status":500}`}, |
| 190 | {"demo", validation.Errors{"err1": validation.NewError("test_code", "test_message")}, `{"data":{"err1":{"code":"test_code","message":"Test_message."}},"message":"Demo.","status":500}`}, |
| 191 | } |
| 192 | |
| 193 | for i, s := range scenarios { |
| 194 | t.Run(strconv.Itoa(i), func(t *testing.T) { |
| 195 | e := router.NewInternalServerError(s.message, s.data) |
| 196 | result, _ := json.Marshal(e) |
| 197 | |
| 198 | if str := string(result); str != s.expected { |
| 199 | t.Fatalf("Expected\n%v\ngot\n%v", s.expected, str) |
| 200 | } |
| 201 | }) |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | func TestNewTooManyRequestsError(t *testing.T) { |
| 206 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…