-
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 api tests for some commands #1747
Conversation
17173e5
to
863e968
Compare
Codecov Report
@@ Coverage Diff @@
## master #1747 +/- ##
==========================================
- Coverage 62.8% 62.72% -0.09%
==========================================
Files 200 200
Lines 15567 15567
==========================================
- Hits 9777 9764 -13
- Misses 4544 4552 +8
- Partials 1246 1251 +5
|
cc @fuweid PTAL, thanks. |
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.
It seems that the change is not only for load
and save
. Could you mind to change the git message and the PR title? Thanks
test/api_image_save_and_load_test.go
Outdated
loadImageName := "load-helloworld" | ||
q = url.Values{} | ||
q.Set("name", loadImageName) | ||
q.Set("quiet", "0") |
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.
I don't think we support the quiet
query here 😄
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.
yes, you are right.
query := request.WithQuery(q) | ||
resp, err := request.Get("/images/save", query) | ||
c.Assert(err, check.IsNil) | ||
defer resp.Body.Close() |
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.
could we use the tmpfile
to store the intermediate result? It seems that it is tricky to use one response body as other request body. 😄
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.
ok, will done soon.
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.
I mean that save the body data into tmpFile
not the var
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.
@fuweid I don't think we should create a new file to store the response data stream, because this is a API test, not client test. In API test I think we handle the http response data is enough. And both save
and load
commands handle the data stream to tar file(or tar file to data stream) in client side, not the http response side. And in other API test, such as api_image_inspect_test
and api_container_inspect_test
, we just use the HTTP response data to check the correctness of this API function. WDYT?
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.
client test includes the api test, I think. cli wrap the client to provide better UEX. for this cases, the api test is same to the cli test. However, you connect two http connections, which is pretty hacking in testing. So I want to save the data in the local and send it again.
It works for me. |
@fuweid Have fixed all bugs, PTAL again, thanks a lot~ |
query := request.WithQuery(q) | ||
resp, err := request.Get("/images/save", query) | ||
c.Assert(err, check.IsNil) | ||
defer resp.Body.Close() |
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.
I mean that save the body data into tmpFile
not the var
Signed-off-by: xiechengsheng <XIE1995@whut.edu.cn>
Unfortunately, The code check CI fails:
pity 📡 @xiechengsheng |
Yes, just now this pr fails on code check, it's my mistake. |
@fuweid Please take a look this pr, thanks a lot~ |
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.
LGTM
Signed-off-by: xiechengsheng XIE1995@whut.edu.cn
Ⅰ. Describe what this PR did
add api tests for some commands.
pause
test.rmi
test.Ⅱ. Does this pull request fix one issue?
NONE
Ⅲ. Describe how you did it
Thanks for @fuweid 's help.
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews