(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestInternalRequestValidate(t *testing.T) { |
| 13 | scenarios := []struct { |
| 14 | name string |
| 15 | request core.InternalRequest |
| 16 | expectedErrors []string |
| 17 | }{ |
| 18 | { |
| 19 | "empty struct", |
| 20 | core.InternalRequest{}, |
| 21 | []string{"method", "url"}, |
| 22 | }, |
| 23 | |
| 24 | // method |
| 25 | { |
| 26 | "GET method", |
| 27 | core.InternalRequest{URL: "test", Method: http.MethodGet}, |
| 28 | []string{}, |
| 29 | }, |
| 30 | { |
| 31 | "POST method", |
| 32 | core.InternalRequest{URL: "test", Method: http.MethodPost}, |
| 33 | []string{}, |
| 34 | }, |
| 35 | { |
| 36 | "PUT method", |
| 37 | core.InternalRequest{URL: "test", Method: http.MethodPut}, |
| 38 | []string{}, |
| 39 | }, |
| 40 | { |
| 41 | "PATCH method", |
| 42 | core.InternalRequest{URL: "test", Method: http.MethodPatch}, |
| 43 | []string{}, |
| 44 | }, |
| 45 | { |
| 46 | "DELETE method", |
| 47 | core.InternalRequest{URL: "test", Method: http.MethodDelete}, |
| 48 | []string{}, |
| 49 | }, |
| 50 | { |
| 51 | "unknown method", |
| 52 | core.InternalRequest{URL: "test", Method: "unknown"}, |
| 53 | []string{"method"}, |
| 54 | }, |
| 55 | |
| 56 | // url |
| 57 | { |
| 58 | "url <= 2000", |
| 59 | core.InternalRequest{URL: strings.Repeat("a", 2000), Method: http.MethodGet}, |
| 60 | []string{}, |
| 61 | }, |
| 62 | { |
| 63 | "url > 2000", |
| 64 | core.InternalRequest{URL: strings.Repeat("a", 2001), Method: http.MethodGet}, |
| 65 | []string{"url"}, |
| 66 | }, |
| 67 | } |
| 68 | |
| 69 | for _, s := range scenarios { |
nothing calls this directly
no test coverage detected
searching dependent graphs…