Skip to content

Commit

Permalink
update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
superbear committed Jun 5, 2024
1 parent ddeaa32 commit c523de9
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions round_robin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,15 @@ func TestRoundRobin(t *testing.T) {

for i, test := range tests {
rr, err := New(test.resources...)

if got, want := !(err == nil), test.iserr; got != want {
t.Errorf("tests[%d] - RoundRobin iserr is wrong. want: %v, but got: %v", i, test.want, got)
if err != nil && !test.iserr {
t.Errorf("tests[%d] - RoundRobin iserr is wrong. want: %v, but got: %v", i, test.want, true)
}

gots := make([]*resource, 0, len(test.want))
for j := 0; j < len(test.want); j++ {
gots = append(gots, rr.Next())
}

if got, want := gots, test.want; !reflect.DeepEqual(got, want) {
t.Errorf("tests[%d] - RoundRobin is wrong. want: %v, got: %v", i, want, got)
got := rr.Next()
if !reflect.DeepEqual(got, test.want[j]) {
t.Errorf("tests[%d] index[%d] - RoundRobin is wrong. want: %v, got: %v", i, j, *test.want[j], *got)
}
}
}
}
Expand Down

0 comments on commit c523de9

Please sign in to comment.