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

object: Improve testing and increase coverage for Object type #634

Merged
merged 9 commits into from
Nov 15, 2024

Conversation

cthulhu-rider
Copy link
Contributor

@cthulhu-rider cthulhu-rider commented Nov 13, 2024

it remains to add tests to the verification fields

Session token is now expected to be signed, and attributes must be
unique.

Signed-off-by: Leonard Lyubich <[email protected]>
@cthulhu-rider cthulhu-rider changed the title Object object: Improve testing and increase coverage for Object type Nov 13, 2024
@cthulhu-rider cthulhu-rider force-pushed the object branch 3 times, most recently from f9974ba to 3f19c06 Compare November 14, 2024 11:39
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 87.01299% with 30 lines in your changes missing coverage. Please review.

Project coverage is 57.44%. Comparing base (ece099d) to head (7d16474).
Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
object/object.go 89.39% 12 Missing and 9 partials ⚠️
client/object_get.go 28.57% 4 Missing and 1 partial ⚠️
object/slicer/slicer.go 71.42% 1 Missing and 1 partial ⚠️
object/link.go 0.00% 1 Missing ⚠️
object/lock.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #634      +/-   ##
==========================================
+ Coverage   56.33%   57.44%   +1.11%     
==========================================
  Files         164      164              
  Lines       22403    22486      +83     
==========================================
+ Hits        12620    12917     +297     
+ Misses       9396     9175     -221     
- Partials      387      394       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cthulhu-rider cthulhu-rider marked this pull request as ready for review November 14, 2024 12:08
object/object.go Outdated Show resolved Hide resolved
object/object.go Outdated Show resolved Hide resolved
@@ -38,7 +38,7 @@ func (o *Object) CalculateAndSetPayloadChecksum() {

// VerifyPayloadChecksum checks if payload checksum in the object
// corresponds to its payload.
func (o *Object) VerifyPayloadChecksum() error {
Copy link
Member

Choose a reason for hiding this comment

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

again: nspcc-dev/.github#29. my biggest concern is why we continue doing this. it is questionable (we do not have the answer on this) but still, we see such commits. we may "fix" it here and have thousands of structs that do not follow this rule. so what's the point?

Copy link
Member

Choose a reason for hiding this comment

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

We're waiting for benchmarks to show copying happens and matters. Then we'll change it back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mostly, existing ro methods are defined on types, not pointers. And some methods like this differ unreasonably. Im tryin to stick them to the most expected view basically. If there will be a particular reason to have a pointer-based method - we'll add it. Currently, there is no reason to pass pointer for payload verification


return true
x.err = dst.ReadFromV2(objv2)
return x.err == nil
Copy link
Member

Choose a reason for hiding this comment

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

immo this is kinda stylish thing: i would prefer to always keep a new line before every return. it used to have it, but now it does not. white space change as @roman-khimov would say. do not insist

Copy link
Member

Choose a reason for hiding this comment

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

It's a bit different, not a pure whitespace change since the logic is changed in these blocks. Works for me both ways.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not an occasional whitespace change like #634 (comment)

Copy link
Member

@carpawell carpawell Nov 15, 2024

Choose a reason for hiding this comment

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

not an occasional whitespace change

i understand but this is also not a new functionality just the old one was changed. i try not to drop/add new lines in such cases even if i have a different style

With 340c369, container/object ID
setter/getter accepts/returns corresponding ID type by value. in a
structural sense, the owner ID of `user.ID` type is no different.
However, its setter and getter were built over pointer to the value.

Now the interface of all identifiers in the object is uniform:
 - setter accepts ID by value;
 - getter returns ID by value;
 - if unset, getter returns zero instance.

Signed-off-by: Leonard Lyubich <[email protected]>
The owner is mandatory and must never be zero.

Signed-off-by: Leonard Lyubich <[email protected]>
Some kind of regression from ade8822:
`Version` method started to return pointer to zero instance instead of
nil. Since the absence of a field and an explicitly set zero are
different cases, the behavior was initially more correct, so this
returns it.

Signed-off-by: Leonard Lyubich <[email protected]>
@roman-khimov roman-khimov merged commit 2da6182 into master Nov 15, 2024
10 checks passed
@roman-khimov roman-khimov deleted the object branch November 15, 2024 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants