Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Validate the single loadbalance.Selector.
- func TestSelectFrom(t *testing.T) {
- cases := []struct {
- hosts []string
- }{
- {}, // 0
- {[]string{}}, // 1
- {[]string{"a"}}, // 2
- {[]string{"a", "b"}}, // 3
- }
- for i, test := range cases {
- a := SelectFrom(test.hosts...)
- // Select returns the first host each time,
- // or empty if no hosts are defined.
- var expect string
- if len(test.hosts) > 0 {
- expect = test.hosts[0]
- }
- // 3 loops all return the same value
- for j := 0; j < 3; j++ {
- if got := a.Select(nil); got != expect {
- t.Errorf("[%d.%d] expected %s got %s", i, j, expect, got)
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment