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

client: fix specificErr handling in SnapshotExport() #13001

Merged
merged 2 commits into from
Jul 26, 2023

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Jul 19, 2023

The code was checking generating a specificErr but then checked if err != nil { (and not check for specificErr) and also lacked a unit test.

When adding the code test it became clear that the other issue there is that the response body was never read so r.err() would always return nil.

This commit fixes both issues.

The code was checking generating a `specificErr` but then checked
`if err != nil {` (and not check for specificErr) and also lacked
a unit test.

When adding the code test it became clear that the other issue
there is that the response body was never read so r.err() would
always return nil.

This commit fixes both issues.
@mvo5 mvo5 added Simple 😃 A small PR which can be reviewed quickly Skip spread Indicate that spread job should not run labels Jul 19, 2023
@@ -142,6 +142,15 @@ func (cs *clientSuite) TestClientCheckSnapshots(c *check.C) {
func (cs *clientSuite) TestClientRestoreSnapshots(c *check.C) {
cs.testClientSnapshotAction(c, "restore", cs.cli.RestoreSnapshots)
}
func (cs *clientSuite) TestClientExportSnapshotSpecificErr(c *check.C) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have also a test where the body is not json formatted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think that would be good, I will see if I can do a small followup here.

client/snapshot_test.go Show resolved Hide resolved
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
@mvo5 mvo5 added the Squash-merge Please squash this PR when merging. label Jul 25, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #13001 (8cf4d48) into master (9431b3f) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master   #13001      +/-   ##
==========================================
+ Coverage   78.67%   78.69%   +0.01%     
==========================================
  Files         999     1000       +1     
  Lines      123889   124140     +251     
==========================================
+ Hits        97474    97691     +217     
- Misses      20279    20300      +21     
- Partials     6136     6149      +13     
Flag Coverage Δ
unittests 78.69% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
client/snapshot.go 87.39% <100.00%> (+2.77%) ⬆️

... and 25 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@olivercalder olivercalder left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@mvo5 mvo5 merged commit c0e8ad5 into canonical:master Jul 26, 2023
alexmurray pushed a commit to alexmurray/snapd that referenced this pull request Oct 17, 2023
* client: fix specificErr handling in SnapshotExport()

The code was checking generating a `specificErr` but then checked
`if err != nil {` (and not check for specificErr) and also lacked
a unit test.

When adding the code test it became clear that the other issue
there is that the response body was never read so r.err() would
always return nil.

This commit fixes both issues.

* client: fix TestClientExportSnapshotSpecificErr naming

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

---------

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Simple 😃 A small PR which can be reviewed quickly Skip spread Indicate that spread job should not run Squash-merge Please squash this PR when merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants