[#189] sdk/netmap: Refactor PlacementPolicy type
Replace alias to v2 type PlacementPolicy with v2-compatible implementation. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
6a29d9c360
commit
9f19139999
5 changed files with 209 additions and 13 deletions
69
pkg/netmap/policy_test.go
Normal file
69
pkg/netmap/policy_test.go
Normal file
|
@ -0,0 +1,69 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPlacementPolicyFromV2(t *testing.T) {
|
||||
pV2 := new(netmap.PlacementPolicy)
|
||||
|
||||
pV2.SetReplicas([]*netmap.Replica{
|
||||
testReplica().ToV2(),
|
||||
testReplica().ToV2(),
|
||||
})
|
||||
|
||||
pV2.SetContainerBackupFactor(3)
|
||||
|
||||
pV2.SetSelectors([]*netmap.Selector{
|
||||
testSelector().ToV2(),
|
||||
testSelector().ToV2(),
|
||||
})
|
||||
|
||||
pV2.SetFilters([]*netmap.Filter{
|
||||
testFilter().ToV2(),
|
||||
testFilter().ToV2(),
|
||||
})
|
||||
|
||||
p := NewPlacementPolicyFromV2(pV2)
|
||||
|
||||
require.Equal(t, pV2, p.ToV2())
|
||||
}
|
||||
|
||||
func TestPlacementPolicy_Replicas(t *testing.T) {
|
||||
p := NewPlacementPolicy()
|
||||
rs := []*Replica{testReplica(), testReplica()}
|
||||
|
||||
p.SetReplicas(rs...)
|
||||
|
||||
require.Equal(t, rs, p.Replicas())
|
||||
}
|
||||
|
||||
func TestPlacementPolicy_ContainerBackupFactor(t *testing.T) {
|
||||
p := NewPlacementPolicy()
|
||||
f := uint32(3)
|
||||
|
||||
p.SetContainerBackupFactor(f)
|
||||
|
||||
require.Equal(t, f, p.ContainerBackupFactor())
|
||||
}
|
||||
|
||||
func TestPlacementPolicy_Selectors(t *testing.T) {
|
||||
p := NewPlacementPolicy()
|
||||
ss := []*Selector{testSelector(), testSelector()}
|
||||
|
||||
p.SetSelectors(ss...)
|
||||
|
||||
require.Equal(t, ss, p.Selectors())
|
||||
}
|
||||
|
||||
func TestPlacementPolicy_Filters(t *testing.T) {
|
||||
p := NewPlacementPolicy()
|
||||
fs := []*Filter{testFilter(), testFilter()}
|
||||
|
||||
p.SetFilters(fs...)
|
||||
|
||||
require.Equal(t, fs, p.Filters())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue