many lint fixes and optimizations (#17)
* util/kubernetes: drop stale files * debug/log/kubernetes: drop stale files * util/scope: remove stale files * util/mdns: drop stale files * lint fixes Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -3,7 +3,6 @@ package roundrobin
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/unistack-org/micro/v3/selector"
|
||||
)
|
||||
|
||||
@@ -19,18 +18,29 @@ func TestRoundRobin(t *testing.T) {
|
||||
// By passing r1 and r2 first, it forces a set sequence of (r1 => r2 => r3 => r1)
|
||||
|
||||
next, err := sel.Select([]string{r1})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r := next()
|
||||
assert.Nil(t, err, "Error should be nil")
|
||||
assert.Equal(t, r1, r, "Expected route to be r1")
|
||||
|
||||
if r1 != r {
|
||||
t.Fatal("Expected route to be r == r1")
|
||||
}
|
||||
|
||||
next, err = sel.Select([]string{r2})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r = next()
|
||||
assert.Nil(t, err, "Error should be nil")
|
||||
assert.Equal(t, r2, r, "Expected route to be r2")
|
||||
if r2 != r {
|
||||
t.Fatal("Expected route to be r2")
|
||||
}
|
||||
|
||||
routes := []string{r1, r2, r3}
|
||||
next, err = sel.Select(routes)
|
||||
assert.Nil(t, err, "Error should be nil")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
n1, n2, n3, n4 := next(), next(), next(), next()
|
||||
|
||||
// start element is random but then it should loop through in order
|
||||
@@ -41,9 +51,19 @@ func TestRoundRobin(t *testing.T) {
|
||||
break
|
||||
}
|
||||
}
|
||||
assert.NotEqual(t, start, -1)
|
||||
assert.Equal(t, routes[start], n1, "Unexpected route")
|
||||
assert.Equal(t, routes[(start+1)%3], n2, "Unexpected route")
|
||||
assert.Equal(t, routes[(start+2)%3], n3, "Unexpected route")
|
||||
assert.Equal(t, routes[(start+3)%3], n4, "Unexpected route")
|
||||
if start == -1 {
|
||||
t.Fatalf("start == -1 %v %v", start, -1)
|
||||
}
|
||||
if routes[start] != n1 {
|
||||
t.Fatal("Unexpected route")
|
||||
}
|
||||
if routes[(start+1)%3] != n2 {
|
||||
t.Fatal("Unexpected route")
|
||||
}
|
||||
if routes[(start+2)%3] != n3 {
|
||||
t.Fatal("Unexpected route")
|
||||
}
|
||||
if routes[(start+3)%3] != n4 {
|
||||
t.Fatal("Unexpected route")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user