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

netmap: add GetAttributes and SetAttributes for NodeInfo #635

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

End-rey
Copy link
Contributor

@End-rey End-rey commented Nov 14, 2024

Refs nspcc-dev/neofs-node#3005 (comment).

I'm not sure about taking out netmap.Attribute. Maybe I need to create my own Attribute?

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.34%. Comparing base (ece099d) to head (41a43d3).
Report is 12 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #635      +/-   ##
==========================================
+ Coverage   56.33%   56.34%   +0.01%     
==========================================
  Files         164      164              
  Lines       22403    22420      +17     
==========================================
+ Hits        12620    12633      +13     
- Misses       9396     9400       +4     
  Partials      387      387              

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

netmap/node_info.go Outdated Show resolved Hide resolved
require.Equal(t, attr2[1], n.Attribute(k2))
require.Equal(t, 2, n.NumberOfAttributes())

n.SetAttributes()
Copy link
Contributor

Choose a reason for hiding this comment

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

essentially this is a reset API which code seems a bit strange to me. I'd replace variadic parameter with a slice. At the same time, passing individual items like few lines above look a bit nicer w/o slicing. But i still stand for slice prm, but dont insist

Copy link
Member

Choose a reason for hiding this comment

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

i am also for slice, but do not insist

require.Equal(t, 2, n.NumberOfAttributes())

n.SetAttributes()
require.Equal(t, 0, n.NumberOfAttributes())
Copy link
Contributor

Choose a reason for hiding this comment

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

require.Zero


n.SetAttributes(attr1)
attrs := n.GetAttributes()
require.Equal(t, len(attrs), n.NumberOfAttributes())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
require.Equal(t, len(attrs), n.NumberOfAttributes())
require.Len(t, attrs, 1)


n.SetAttributes(attr1, attr2)
attrs = n.GetAttributes()
require.Equal(t, len(attrs), n.NumberOfAttributes())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
require.Equal(t, len(attrs), n.NumberOfAttributes())
require.Len(t, attrs, 2)

netmap/node_info.go Outdated Show resolved Hide resolved
require.Equal(t, attr2[1], n.Attribute(k2))
require.Equal(t, 2, n.NumberOfAttributes())

n.SetAttributes()
Copy link
Member

Choose a reason for hiding this comment

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

i am also for slice, but do not insist

@roman-khimov roman-khimov merged commit eb97b11 into master Nov 15, 2024
10 checks passed
@roman-khimov roman-khimov deleted the node-info-set-get-attributes branch November 15, 2024 19:22
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.

4 participants