As a user of felice, which is great, by the way, I'd like to test what I'm actually sending, that is, topic, body and key. I am using a mock of the producer Send function, which looks like that:
p.SendFunc = func(_ context.Context, topic string, v interface{}, opts ...fproducer.Option) (*fproducer.Message, error) {
// Test the body
require.Equal(t, &Object{}, v)
// Test topic
require.Equal(t, "my-topic", topic)
// Test the key
mess := producer.NewMessage(topic, "")
opts[0](mess)
k, err := mess.Key.Encode()
require.NoError(t, err)
require.Equal(t, "awesome-key", string(k))
The last part is almost impossible to write it without knowing all insights of library. Is there any better way to test it given the previous constraint? If so, I'd love to have it documented in godoc, if not, a helper would be great :)