[#354] api/netmap: Return a slice of parameters directly
`IterateParameters` does a poor job: - it doesn't encapsulate well, because it returns a pointer, - it has a clunky interface, compared to range loop. I have decided to return parameter slice and not `iter.Seq` for 2 reasons: 1. There already is `SetParameters`, so `NetworkConfig` struct is expected to be modified. 2. This iterator uses pointers, so even with this interface the slice can already be changed. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
661adf17bb
commit
16fd3bafe0
3 changed files with 38 additions and 53 deletions
|
@ -76,16 +76,10 @@ func testConfigValue(t *testing.T,
|
|||
var m netmap.NetworkInfo
|
||||
x.WriteToV2(&m)
|
||||
|
||||
require.EqualValues(t, 1, m.GetNetworkConfig().NumberOfParameters())
|
||||
found := false
|
||||
m.GetNetworkConfig().IterateParameters(func(prm *netmap.NetworkParameter) bool {
|
||||
require.False(t, found)
|
||||
require.Equal(t, []byte(v2Key), prm.GetKey())
|
||||
require.Equal(t, v2Val(exp), prm.GetValue())
|
||||
found = true
|
||||
return false
|
||||
})
|
||||
require.True(t, found)
|
||||
var p netmap.NetworkParameter
|
||||
p.SetKey([]byte(v2Key))
|
||||
p.SetValue(v2Val(exp))
|
||||
require.Equal(t, []netmap.NetworkParameter{p}, m.GetNetworkConfig().Parameters())
|
||||
}
|
||||
|
||||
setter(&x, val1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue