Codebase list golang-github-go-kit-kit / 3492c8c
Satisfy the misspell gods Peter Bourgon 7 years ago
3 changed file(s) with 8 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
3939
4040 // Switch the endpoint to start throwing errors.
4141 m.err = errors.New("tragedy+disaster")
42 m.thru = 0
42 m.through = 0
4343
4444 // The first several should be allowed through and yield our error.
4545 for i := 0; shouldPass(i); i++ {
4848 }
4949 time.Sleep(requestDelay)
5050 }
51 thru := m.thru
51 through := m.through
5252
5353 // But the rest should be blocked by an open circuit.
5454 for i := 0; i < 10; i++ {
5959 }
6060
6161 // 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 {
6363 t.Errorf("%s: want %d, have %d", caller, want, have)
6464 }
6565 }
6666
6767 type mock struct {
68 thru int
68 through int
6969 err error
7070 }
7171
7272 func (m *mock) endpoint(context.Context, interface{}) (interface{}, error) {
73 m.thru++
73 m.through++
7474 return struct{}{}, m.err
7575 }
2929 // Add implements Counter.
3030 func (c *Counter) Add(delta float64) { c.f.Add(delta) }
3131
32 // Gauge implements the gauge metric wtih an expvar float.
32 // Gauge implements the gauge metric with an expvar float.
3333 // Label values are not supported.
3434 type Gauge struct {
3535 f *expvar.Float
2525 t.Fatal("nil conn")
2626 }
2727
28 // Write and check it went thru.
28 // Write and check it went through.
2929 if _, err := conn.Write([]byte{1, 2, 3}); err != nil {
3030 t.Fatal(err)
3131 }
5454 t.Fatal("conn remained nil")
5555 }
5656
57 // Write and check it went thru.
57 // Write and check it went through.
5858 if _, err := conn.Write([]byte{4, 5}); err != nil {
5959 t.Fatal(err)
6060 }