assertRequest checks for the request method and path. If the expected path does not contain a version prefix, it is prefixed with the current API version.
(req *http.Request, expMethod string, expectedPath string)
| 21 | // path does not contain a version prefix, it is prefixed with the current API |
| 22 | // version. |
| 23 | func assertRequest(req *http.Request, expMethod string, expectedPath string) error { |
| 24 | if !strings.HasPrefix(expectedPath, "/v1.") { |
| 25 | expectedPath = defaultAPIPath + expectedPath |
| 26 | } |
| 27 | if !strings.HasPrefix(req.URL.Path, expectedPath) { |
| 28 | return fmt.Errorf("expected URL '%s', got '%s'", expectedPath, req.URL.Path) |
| 29 | } |
| 30 | if req.Method != expMethod { |
| 31 | return fmt.Errorf("expected %s method, got %s", expMethod, req.Method) |
| 32 | } |
| 33 | return nil |
| 34 | } |
| 35 | |
| 36 | func assertRequestWithQuery(req *http.Request, expMethod string, expectedPath string, expectedQuery string) error { |
| 37 | if err := assertRequest(req, expMethod, expectedPath); err != nil { |
no test coverage detected
searching dependent graphs…