MCPcopy
hub / github.com/moby/moby / assertRequest

Function assertRequest

client/client_mock_test.go:23–34  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

21// path does not contain a version prefix, it is prefixed with the current API
22// version.
23func 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
36func assertRequestWithQuery(req *http.Request, expMethod string, expectedPath string, expectedQuery string) error {
37 if err := assertRequest(req, expMethod, expectedPath); err != nil {

Callers 15

TestConfigUpdateFunction · 0.85
TestNetworkConnectFunction · 0.85
TestPluginPushFunction · 0.85
TestImageInspectFunction · 0.85
TestImageListFunction · 0.85
TestContainerRestartFunction · 0.85
TestCheckpointListFunction · 0.85
TestServiceCreateFunction · 0.85
TestTaskListFunction · 0.85
TestExecCreateFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…