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 container create test #1106

Merged
merged 1 commit into from
Apr 12, 2018

Conversation

Dewey-Ding
Copy link
Contributor

Signed-off-by: Dewey-Ding deweyding@gmail.com

Ⅰ. Describe what this PR did

add container create test

Ⅱ. Does this pull request fix one issue?

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-io
Copy link

codecov-io commented Apr 11, 2018

Codecov Report

Merging #1106 into master will increase coverage by 0.94%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1106      +/-   ##
==========================================
+ Coverage    15.8%   16.75%   +0.94%     
==========================================
  Files         163      165       +2     
  Lines        8793     8906     +113     
==========================================
+ Hits         1390     1492     +102     
- Misses       7300     7308       +8     
- Partials      103      106       +3
Impacted Files Coverage Δ
client/container.go 0% <ø> (ø) ⬆️
client/container_create.go 100% <100%> (ø)
cli/command.go 0% <0%> (ø)
pkg/utils/utils.go 78.15% <0%> (+3.15%) ⬆️

httpClient := newMockClient(func(req *http.Request) (*http.Response, error) {
if !strings.HasPrefix(req.URL.Path, expectedURL) {
return nil, fmt.Errorf("expected URL '%s', got '%s'", expectedURL, req.URL)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this test can be enhanced. Would you check the type of the request or the data type that the request method gets, which can improve the degree of accuracy greatly. Thx a lot!

}
if container.ID != "container_id" {
t.Fatalf("expected `container_id`, got %s", container.ID)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can assert the value of both id and name here, instead of just that of id.

@ZouRui89
Copy link
Contributor

You can refer to similar mock test, such as 'network create' and 'volume create'.

Signed-off-by: Dewey-Ding <deweyding@gmail.com>
@Dewey-Ding
Copy link
Contributor Author

@ZouRui89 PTAL

@ZouRui89
Copy link
Contributor

Well done! LGTM

@ZouRui89 ZouRui89 merged commit 0a5702c into AliyunContainerService:master Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants