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

Method Run

mock/mock.go:183–188  ·  view source on GitHub ↗

Run sets a handler to be called before returning. It can be used when mocking a method (such as an unmarshaler) that takes a pointer to a struct and sets properties in such struct Mock.On("Unmarshal", AnythingOfType("*map[string]interface{}")).Return().Run(func(args Arguments) { arg := args.Get(

(fn func(args Arguments))

Source from the content-addressed store, hash-verified

181// arg["foo"] = "bar"
182// })
183func (c *Call) Run(fn func(args Arguments)) *Call {
184 c.lock()
185 defer c.unlock()
186 c.RunFn = fn
187 return c
188}
189
190// Maybe allows the method call to be optional. Not calling an optional method
191// will not cause an error while asserting expectations

Callers 15

Test_Mock_Return_RunFunction · 0.45
Test_WaitUntil_ParallelFunction · 0.45
TestObjectsAreEqualFunction · 0.45
TestCopyExportedFieldsFunction · 0.45
TestEqualExportedValuesFunction · 0.45
TestEqualFunction · 0.45
Test_samePointersFunction · 0.45
TestExactlyFunction · 0.45

Calls 2

lockMethod · 0.95
unlockMethod · 0.95

Tested by 15

Test_Mock_Return_RunFunction · 0.36
Test_WaitUntil_ParallelFunction · 0.36
TestObjectsAreEqualFunction · 0.36
TestCopyExportedFieldsFunction · 0.36
TestEqualExportedValuesFunction · 0.36
TestEqualFunction · 0.36
Test_samePointersFunction · 0.36
TestExactlyFunction · 0.36