MockNetConn: Add ExpectNothing() helper.

This commit is contained in:
Alex Bramley 2011-08-23 10:44:14 +01:00
parent bd388db1cc
commit 59b18b038b
1 changed files with 11 additions and 0 deletions

View File

@ -88,6 +88,17 @@ func (m *mockNetConn) Expect(e string) {
} }
} }
func (m *mockNetConn) ExpectNothing() {
t := time.NewTimer(5e6)
select {
case <-t.C:
case s := <-m.Out:
t.Stop()
m.Errorf("Mock connection received unexpected output.\n\t" +
"Expected nothing, got: '%s'", s)
}
}
// Implement net.Conn interface // Implement net.Conn interface
func (m *mockNetConn) Read(b []byte) (int, os.Error) { func (m *mockNetConn) Read(b []byte) (int, os.Error) {
if m.closed { if m.closed {