Skip to content

Commit

Permalink
Improve docs and error output for mock relay stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshay Shah committed Jun 11, 2016
1 parent 633dc3b commit 130714c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions relay/fakes.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func (n noopCallStats) End() {}

// MockCallStats is a testing spy for the CallStats interface.
type MockCallStats struct {
// Store ints and slices instead of bools and strings so that we can assert
// the actual sequence of calls (in case we expect to call both Succeeded
// and Failed). The real implementation will have the first writer win.
succeeded int
failedMsgs []string
ended int
Expand Down Expand Up @@ -143,6 +146,10 @@ func (m *MockStats) assertCallEqual(t testing.TB, expected *MockCallStats, actua
assert.Equal(t, expected.succeeded, actual.succeeded, "Unexpected number of successes.")
assert.Equal(t, expected.failedMsgs, actual.failedMsgs, "Unexpected reasons for RPC failure.")
assert.Equal(t, expected.ended, actual.ended, "Unexpected number of calls to End.")
if t.Failed() {
// The default testify output is often insufficient.
t.Logf("\nExpected relayed stats were:\n\t%+v\nActual relayed stats were:\n\t%+v\n", expected, actual)
}
}

func (m *MockStats) tripleToKey(caller, callee, procedure string) string {
Expand Down

0 comments on commit 130714c

Please sign in to comment.