[#1648] morph: Change endpoint priority order
The lowest value means the highest priority. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
2467be0117
commit
a97dee008c
10 changed files with 67 additions and 17 deletions
29
pkg/morph/client/multy_test.go
Normal file
29
pkg/morph/client/multy_test.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestInitEndpoints(t *testing.T) {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
ee := make([]Endpoint, 100)
|
||||
for i := range ee {
|
||||
ee[i].Priority = rand.Int()
|
||||
}
|
||||
|
||||
var eeInternal endpoints
|
||||
eeInternal.init(ee)
|
||||
|
||||
prevValue := eeInternal.list[0].Priority
|
||||
|
||||
for _, e := range eeInternal.list {
|
||||
require.True(t, prevValue <= e.Priority)
|
||||
|
||||
prevValue = e.Priority
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue