MCPcopy
hub / github.com/stretchr/testify / Test_WaitUntil_Parallel

Function Test_WaitUntil_Parallel

mock/mock_test.go:2085–2110  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2083}
2084
2085func Test_WaitUntil_Parallel(t *testing.T) {
2086 t.Parallel()
2087
2088 // make a test impl object
2089 var mockedService = new(TestExampleImplementation)
2090
2091 ch1 := make(chan time.Time)
2092 ch2 := make(chan time.Time)
2093
2094 mockedService.Mock.On("TheExampleMethod2", true).Return().WaitUntil(ch2).Run(func(args Arguments) {
2095 ch1 <- time.Now()
2096 })
2097
2098 mockedService.Mock.On("TheExampleMethod2", false).Return().WaitUntil(ch1)
2099
2100 // Lock both goroutines on the .WaitUntil method
2101 go func() {
2102 mockedService.TheExampleMethod2(false)
2103 }()
2104 go func() {
2105 mockedService.TheExampleMethod2(true)
2106 }()
2107
2108 // Allow the first call to execute, so the second one executes afterwards
2109 ch2 <- time.Now()
2110}
2111
2112func Test_MockMethodCalled(t *testing.T) {
2113 t.Parallel()

Callers

nothing calls this directly

Calls 5

WaitUntilMethod · 0.80
ReturnMethod · 0.80
TheExampleMethod2Method · 0.80
RunMethod · 0.45
OnMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…