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

feat: add read and verify utility method #324

Merged
merged 11 commits into from
Sep 21, 2022
Merged

feat: add read and verify utility method #324

merged 11 commits into from
Sep 21, 2022

Conversation

wangxiaoxuan273
Copy link
Contributor

@wangxiaoxuan273 wangxiaoxuan273 commented Sep 19, 2022

Added VerifyReader struct that performs verification against the digest and size when reading content. Changed CopyBuffer to use VerifyReader.

resolves #306

Signed-off-by: wangxiaoxuan273 wangxiaoxuan119@gmail.com

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Sep 19, 2022

Codecov Report

Merging #324 (757cc1f) into main (524c614) will increase coverage by 0.62%.
The diff coverage is 91.04%.

@@            Coverage Diff             @@
##             main     #324      +/-   ##
==========================================
+ Coverage   71.79%   72.42%   +0.62%     
==========================================
  Files          38       38              
  Lines        3584     3615      +31     
==========================================
+ Hits         2573     2618      +45     
+ Misses        754      738      -16     
- Partials      257      259       +2     
Impacted Files Coverage Δ
content/reader.go 90.62% <90.62%> (ø)
internal/ioutil/io.go 85.71% <100.00%> (+67.19%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
@wangxiaoxuan273
Copy link
Contributor Author

Should I add unit tests to CopyBuffer? I'm afraid I'll totally break it.

Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

We need more test cases for edge cases

content/reader.go Outdated Show resolved Hide resolved
content/reader.go Outdated Show resolved Hide resolved
content/reader.go Outdated Show resolved Hide resolved
internal/ioutil/io.go Outdated Show resolved Hide resolved
content/reader.go Show resolved Hide resolved
content/reader.go Show resolved Hide resolved
content/reader.go Outdated Show resolved Hide resolved
content/reader.go Show resolved Hide resolved
internal/ioutil/io.go Outdated Show resolved Hide resolved
content/reader_test.go Show resolved Hide resolved
content/reader_test.go Show resolved Hide resolved
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
@wangxiaoxuan273
Copy link
Contributor Author

wangxiaoxuan273 commented Sep 20, 2022

Should I add unit tests to CopyBuffer? I'm afraid I'll totally break it.

Added some unit tests to CopyBuffer.

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
internal/ioutil/io.go Outdated Show resolved Hide resolved
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
@shizhMSFT shizhMSFT added this to the v2.0.0-rc.4 milestone Sep 20, 2022
content/example_test.go Outdated Show resolved Hide resolved
content/example_test.go Outdated Show resolved Hide resolved
content/example_test.go Outdated Show resolved Hide resolved
internal/ioutil/io_test.go Show resolved Hide resolved
content/reader_test.go Show resolved Hide resolved
content/reader_test.go Show resolved Hide resolved
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
internal/ioutil/io_test.go Outdated Show resolved Hide resolved
internal/ioutil/io_test.go Show resolved Hide resolved
content/example_test.go Outdated Show resolved Hide resolved
content/reader_test.go Outdated Show resolved Hide resolved
content/reader_test.go Show resolved Hide resolved
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
@wangxiaoxuan273 wangxiaoxuan273 requested review from Wwwsylvia and shizhMSFT and removed request for Wwwsylvia September 20, 2022 09:30
content/reader.go Outdated Show resolved Hide resolved
content/reader.go Outdated Show resolved Hide resolved
Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

@shizhMSFT shizhMSFT merged commit 34e7e6f into oras-project:main Sep 21, 2022
@wangxiaoxuan273 wangxiaoxuan273 deleted the reader branch September 21, 2022 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Utility method for verifying content from reader
4 participants