Satisfy the misspell gods
Peter Bourgon
7 years ago
39 | 39 |
|
40 | 40 |
// Switch the endpoint to start throwing errors.
|
41 | 41 |
m.err = errors.New("tragedy+disaster")
|
42 | |
m.thru = 0
|
|
42 |
m.through = 0
|
43 | 43 |
|
44 | 44 |
// The first several should be allowed through and yield our error.
|
45 | 45 |
for i := 0; shouldPass(i); i++ {
|
|
48 | 48 |
}
|
49 | 49 |
time.Sleep(requestDelay)
|
50 | 50 |
}
|
51 | |
thru := m.thru
|
|
51 |
through := m.through
|
52 | 52 |
|
53 | 53 |
// But the rest should be blocked by an open circuit.
|
54 | 54 |
for i := 0; i < 10; i++ {
|
|
59 | 59 |
}
|
60 | 60 |
|
61 | 61 |
// Make sure none of those got through.
|
62 | |
if want, have := thru, m.thru; want != have {
|
|
62 |
if want, have := through, m.through; want != have {
|
63 | 63 |
t.Errorf("%s: want %d, have %d", caller, want, have)
|
64 | 64 |
}
|
65 | 65 |
}
|
66 | 66 |
|
67 | 67 |
type mock struct {
|
68 | |
thru int
|
|
68 |
through int
|
69 | 69 |
err error
|
70 | 70 |
}
|
71 | 71 |
|
72 | 72 |
func (m *mock) endpoint(context.Context, interface{}) (interface{}, error) {
|
73 | |
m.thru++
|
|
73 |
m.through++
|
74 | 74 |
return struct{}{}, m.err
|
75 | 75 |
}
|
29 | 29 |
// Add implements Counter.
|
30 | 30 |
func (c *Counter) Add(delta float64) { c.f.Add(delta) }
|
31 | 31 |
|
32 | |
// Gauge implements the gauge metric wtih an expvar float.
|
|
32 |
// Gauge implements the gauge metric with an expvar float.
|
33 | 33 |
// Label values are not supported.
|
34 | 34 |
type Gauge struct {
|
35 | 35 |
f *expvar.Float
|
25 | 25 |
t.Fatal("nil conn")
|
26 | 26 |
}
|
27 | 27 |
|
28 | |
// Write and check it went thru.
|
|
28 |
// Write and check it went through.
|
29 | 29 |
if _, err := conn.Write([]byte{1, 2, 3}); err != nil {
|
30 | 30 |
t.Fatal(err)
|
31 | 31 |
}
|
|
54 | 54 |
t.Fatal("conn remained nil")
|
55 | 55 |
}
|
56 | 56 |
|
57 | |
// Write and check it went thru.
|
|
57 |
// Write and check it went through.
|
58 | 58 |
if _, err := conn.Write([]byte{4, 5}); err != nil {
|
59 | 59 |
t.Fatal(err)
|
60 | 60 |
}
|