-
Notifications
You must be signed in to change notification settings - Fork 949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: add mock test for image operations on client side #1032
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some tiny issue added in the pr code review comment.
client/image_inspect_test.go
Outdated
} | ||
} | ||
|
||
func TestImageInspectNoFoundError(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NotFound
, rather than NoFound
.
client/image_inspect_test.go
Outdated
|
||
func TestImageInspectNoFoundError(t *testing.T) { | ||
client := &APIClient{ | ||
HTTPCli: newMockClient(errorMockResponse(http.StatusConflict, "Not Found")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NotFound's status code should be http.StatusNotFound
client/image_pull_test.go
Outdated
if !strings.HasPrefix(req.URL.Path, expectedURL) { | ||
return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL) | ||
} | ||
if req.Header.Get("Content-Type") == "application/json" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ImagePull does not set the header of application/json
, see https://github.com/moby/moby/blob/master/api/swagger.yaml#L6296-L6297
Please find out which a better to fix this.
client/image_pull_test.go
Outdated
return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL) | ||
} | ||
if req.Header.Get("Content-Type") == "application/json" { | ||
createConfig := types.NetworkCreateConfig{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No network is related. And ImagePulll will not involve a config in the request body.
client/image_pull_test.go
Outdated
} | ||
|
||
return &http.Response{ | ||
StatusCode: http.StatusCreated, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StatusOK
Codecov Report
@@ Coverage Diff @@
## master #1032 +/- ##
==========================================
+ Coverage 15.18% 15.61% +0.43%
==========================================
Files 135 138 +3
Lines 8483 8483
==========================================
+ Hits 1288 1325 +37
+ Misses 7094 7058 -36
+ Partials 101 100 -1
Continue to review full report at Codecov.
|
Signed-off-by: Zou Rui <[email protected]>
LGTM |
Signed-off-by: Zou Rui [email protected]
Ⅰ. Describe what this PR did
add mock test for image operations on client side
Ⅱ. Does this pull request fix one issue?
Ⅲ. Describe how you did it
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews