Added test to avoid regresions of #167.

pull/171/head
Antonio Nicolás Pina 2015-05-20 10:14:16 +03:00
parent 547cd8eed6
commit 4a6e51647d
1 changed files with 26 additions and 0 deletions

View File

@ -841,3 +841,29 @@ func Test_Arguments_Bool(t *testing.T) {
assert.Equal(t, true, args.Bool(2))
}
func Test_WaitUntil_Parallel(t *testing.T) {
// make a test impl object
var mockedService *TestExampleImplementation = new(TestExampleImplementation)
ch1 := make(chan time.Time)
ch2 := make(chan time.Time)
mockedService.Mock.On("TheExampleMethod2", true).Return().WaitUntil(ch2).Run(func(args Arguments) {
ch1 <- time.Now()
})
mockedService.Mock.On("TheExampleMethod2", false).Return().WaitUntil(ch1)
// Lock both goroutines on the .WaitUntil method
go func() {
mockedService.TheExampleMethod2(false)
}()
go func() {
mockedService.TheExampleMethod2(true)
}()
// Allow the first call to execute, so the second one executes afterwards
ch2 <- time.Now()
}