(t *testing.T)
| 26 | ) |
| 27 | |
| 28 | func TestIsRoundRobin(t *testing.T) { |
| 29 | var ( |
| 30 | sc1 = &testutils.TestSubConn{} |
| 31 | sc2 = &testutils.TestSubConn{} |
| 32 | sc3 = &testutils.TestSubConn{} |
| 33 | ) |
| 34 | |
| 35 | testCases := []struct { |
| 36 | desc string |
| 37 | want []balancer.SubConn |
| 38 | got []balancer.SubConn |
| 39 | pass bool |
| 40 | }{ |
| 41 | { |
| 42 | desc: "0 element", |
| 43 | want: []balancer.SubConn{}, |
| 44 | got: []balancer.SubConn{}, |
| 45 | pass: true, |
| 46 | }, |
| 47 | { |
| 48 | desc: "1 element RR", |
| 49 | want: []balancer.SubConn{sc1}, |
| 50 | got: []balancer.SubConn{sc1, sc1, sc1, sc1}, |
| 51 | pass: true, |
| 52 | }, |
| 53 | { |
| 54 | desc: "1 element not RR", |
| 55 | want: []balancer.SubConn{sc1}, |
| 56 | got: []balancer.SubConn{sc1, sc2, sc1}, |
| 57 | pass: false, |
| 58 | }, |
| 59 | { |
| 60 | desc: "2 elements RR", |
| 61 | want: []balancer.SubConn{sc1, sc2}, |
| 62 | got: []balancer.SubConn{sc1, sc2, sc1, sc2, sc1, sc2}, |
| 63 | pass: true, |
| 64 | }, |
| 65 | { |
| 66 | desc: "2 elements RR different order from want", |
| 67 | want: []balancer.SubConn{sc2, sc1}, |
| 68 | got: []balancer.SubConn{sc1, sc2, sc1, sc2, sc1, sc2}, |
| 69 | pass: true, |
| 70 | }, |
| 71 | { |
| 72 | desc: "2 elements RR not RR, mistake in first iter", |
| 73 | want: []balancer.SubConn{sc1, sc2}, |
| 74 | got: []balancer.SubConn{sc1, sc1, sc1, sc2, sc1, sc2}, |
| 75 | pass: false, |
| 76 | }, |
| 77 | { |
| 78 | desc: "2 elements RR not RR, mistake in second iter", |
| 79 | want: []balancer.SubConn{sc1, sc2}, |
| 80 | got: []balancer.SubConn{sc1, sc2, sc1, sc1, sc1, sc2}, |
| 81 | pass: false, |
| 82 | }, |
| 83 | { |
| 84 | desc: "2 elements weighted RR", |
| 85 | want: []balancer.SubConn{sc1, sc1, sc2}, |
nothing calls this directly
no test coverage detected