Simplify retry test
Peter Bourgon
8 years ago
17 | 17 | lb = loadbalancer.RoundRobin(p) |
18 | 18 | ) |
19 | 19 | |
20 | { | |
21 | max := 999 | |
22 | e := loadbalancer.Retry(max, lb) | |
23 | if _, err := e(context.Background(), struct{}{}); err == nil { | |
24 | t.Errorf("expected error, got none") | |
25 | } | |
20 | if _, err := loadbalancer.Retry(999, lb)(context.Background(), struct{}{}); err == nil { | |
21 | t.Errorf("expected error, got none") | |
26 | 22 | } |
27 | 23 | |
28 | 24 | endpoints = []endpoint.Endpoint{ |
33 | 29 | p.Replace(endpoints) |
34 | 30 | runtime.Gosched() |
35 | 31 | |
36 | { | |
37 | max := len(endpoints) - 1 | |
38 | e := loadbalancer.Retry(max, lb) | |
39 | if _, err := e(context.Background(), struct{}{}); err == nil { | |
40 | t.Errorf("expected error, got none") | |
41 | } | |
32 | if _, err := loadbalancer.Retry(len(endpoints)-1, lb)(context.Background(), struct{}{}); err == nil { | |
33 | t.Errorf("expected error, got none") | |
42 | 34 | } |
43 | 35 | |
44 | { | |
45 | max := len(endpoints) | |
46 | e := loadbalancer.Retry(max, lb) | |
47 | if _, err := e(context.Background(), struct{}{}); err != nil { | |
48 | t.Error(err) | |
49 | } | |
36 | if _, err := loadbalancer.Retry(len(endpoints), lb)(context.Background(), struct{}{}); err != nil { | |
37 | t.Error(err) | |
50 | 38 | } |
51 | 39 | } |