Skip to content
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

Merged
merged 1 commit into from
Apr 3, 2018
Merged

test: add mock test for image operations on client side #1032

merged 1 commit into from
Apr 3, 2018

Conversation

ZouRui89
Copy link
Contributor

@ZouRui89 ZouRui89 commented Apr 2, 2018

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

Copy link
Collaborator

@allencloud allencloud left a 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.

}
}

func TestImageInspectNoFoundError(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NotFound, rather than NoFound.


func TestImageInspectNoFoundError(t *testing.T) {
client := &APIClient{
HTTPCli: newMockClient(errorMockResponse(http.StatusConflict, "Not Found")),
Copy link
Collaborator

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

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" {
Copy link
Collaborator

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.

return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
}
if req.Header.Get("Content-Type") == "application/json" {
createConfig := types.NetworkCreateConfig{}
Copy link
Collaborator

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.

}

return &http.Response{
StatusCode: http.StatusCreated,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StatusOK

@codecov-io
Copy link

codecov-io commented Apr 2, 2018

Codecov Report

Merging #1032 into master will increase coverage by 0.43%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
client/image_pull.go 100% <100%> (ø)
client/image_remove.go 100% <100%> (ø)
client/image_list.go 100% <100%> (ø)
client/image_inspect.go 100% <100%> (ø)
client/request.go 58.53% <0%> (+3.65%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 85d808d...26dc593. Read the comment docs.

@allencloud
Copy link
Collaborator

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Apr 3, 2018
@allencloud allencloud merged commit 5dbe6ea into AliyunContainerService:master Apr 3, 2018
@ZouRui89 ZouRui89 deleted the mock_image branch April 3, 2018 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
areas/test LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants