Commit Graph

118 Commits (1419-fail-assertions)

Author SHA1 Message Date
Ernesto Jiménez 0792dedcd1 Mock can block returns with .After and .WaitUntil
You sometimes want to test concurrent behaviour like timeouts, but it
was not currently possible with our mocks.

This commits adds the following functions to Mock:

`After` will block m.Called for the given duration before returning.

```golang
func (m *Mock) After(d time.Duration) *Mock

Mock.On("MyMethod", arg1).After(1 * time.Millisecond)
```

`WaitUntil` is the primitive under `After`, and it's exposed in case you
want somebody wants more control over the returns. `Called` blocks until the w
channel is closed or receives a message.

```golang
func (m *Mock) WaitUntil(w <-chan time.Time) *Mock

Mock.On("MyMethod", arg1).WaitUntil(time.After(1 * time.Millisecond))
```
2015-04-07 23:42:31 +01:00
Christian Mesh 5d4510b137 Fix mock.go's Int Bool and Error shortcut methods
When using testify, I saw panic: assert: arguments: Error(0) failed because object wasn't correct type: {{ad6e7d77-1745-4761-6c4b-a79ab92a4a0f e6e975ef-3637-4047-436a-018ee9d2de52 %!s(int=17) <nil> <nil> %!s(bool=false) %!s(*string=<nil>) ...
when using the Error(index) function.

This commit simply changes to using %v for printing the unexpected structure in the Bool, Int, and Error shortcut methods.
2014-10-15 14:01:54 -04:00
Anup Chenthamarakshan 27b04ffad0 Fix issue #55 - Serialize calls to Mock.Called. 2014-07-11 22:17:41 -07:00
Pieter Noordhuis 939e66beb2 Fix use of AnythingOfType with AssertCalled 2014-04-01 15:52:39 -07:00
Onsi Fakhouri 59b459277c Define a TestingT interface in assertions.go and mock.go 2014-01-20 18:25:43 -08:00
Mariano Cano 84b345c662 Fix support for AnythingOfTypeArgument. 2013-12-05 10:18:56 -08:00
Curtis Schlak ab70c9a56c Now expectations for method calls abides the repeatability argument. 2013-10-04 23:19:54 -05:00
Curtis Schlak 40e4720477 Added repeatability to On/Return expectations. 2013-10-04 23:15:50 -05:00
Tyler Bunnell 855b03c899 objx transition complete 2013-09-17 16:17:34 -06:00
Tyler Bunnell f3d115a597 Remove unreachable code 2013-06-12 09:35:26 -06:00
Mat Ryer ae878dc5c4 repo name change 2013-06-11 22:44:58 -06:00
Mat Ryer d6863491da fixed bug in String 2013-04-30 10:40:31 -06:00
Mat Ryer 87ce1d3239 added TestData to mocks 2013-04-30 10:35:18 -06:00
Tyler Bunnell 044591a481 go fmt 2013-03-31 09:56:37 -06:00
Tyler Bunnell 85763a0f23 Sprint->Sprintf 2013-03-31 09:42:14 -06:00
Tyler Bunnell cfc83347cf Remove unreachable code 2013-03-31 09:41:59 -06:00
Tyler Bunnell 8014de2adc Fixes #5 2012-10-17 16:22:11 -06:00
Tyler Bunnell 2930d903bf Initial Commit 2012-10-16 11:14:23 -06:00