Proposal: assert.Called
Often I have to test that a function is called and I use boolean flags. One flag is alright, but when I need more things get ugly.
My suggestion is to add a new method that simplifies that, similar to the one in mock package, but in assert package, something like:
func TestExample(t *testing.T) {
assert := assert.New(t)
h := MyHandler(
func() {
assert.AddCall("Func One")
},
func() {
assert.AddCall("Func Two")
},
)
h(nil, nil)
assert.Called("Func One", "Func Two")
}
I don't think this should be added to the assert package. I can see what you mean, but what you are describing is a mock and there is already a mock package. The actual mock package can also make more complex assertions around the callback you are expecting such as testing arguments and returning values. This also feels a bit like trying to make your Go more terse at the cost of readability, I would prefer two bool vars in this more trivial example.