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 was merged in pull request #17.
This commit is contained in:
@@ -2,8 +2,6 @@ package selector
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// Tests runs all the tests against a selector to ensure the implementations are consistent
|
||||
@@ -14,19 +12,27 @@ func Tests(t *testing.T, s Selector) {
|
||||
t.Run("Select", func(t *testing.T) {
|
||||
t.Run("NoRoutes", func(t *testing.T) {
|
||||
_, err := s.Select([]string{})
|
||||
assert.Equal(t, ErrNoneAvailable, err, "Expected error to be none available")
|
||||
if err != ErrNoneAvailable {
|
||||
t.Fatal("Expected error to be none available")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("OneRoute", func(t *testing.T) {
|
||||
next, err := s.Select([]string{r1})
|
||||
if err != nil {
|
||||
t.Fatal("Error should be nil")
|
||||
}
|
||||
srv := next()
|
||||
assert.Nil(t, err, "Error should be nil")
|
||||
assert.Equal(t, r1, srv, "Expected the route to be returned")
|
||||
if r1 != srv {
|
||||
t.Fatal("Expected the route to be returned")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("MultipleRoutes", func(t *testing.T) {
|
||||
next, err := s.Select([]string{r1, r2})
|
||||
assert.Nil(t, err, "Error should be nil")
|
||||
if err != nil {
|
||||
t.Fatal("Error should be nil")
|
||||
}
|
||||
srv := next()
|
||||
if srv != r1 && srv != r2 {
|
||||
t.Errorf("Expected the route to be one of the inputs")
|
||||
@@ -35,11 +41,14 @@ func Tests(t *testing.T, s Selector) {
|
||||
})
|
||||
|
||||
t.Run("Record", func(t *testing.T) {
|
||||
err := s.Record(r1, nil)
|
||||
assert.Nil(t, err, "Expected the error to be nil")
|
||||
if err := s.Record(r1, nil); err != nil {
|
||||
t.Fatal("Expected the error to be nil")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("String", func(t *testing.T) {
|
||||
assert.NotEmpty(t, s.String(), "String returned a blank string")
|
||||
if s.String() == "" {
|
||||
t.Fatal("String returned a blank string")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user