Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Ease producer testing #36

@sixstone-qq

Description

@sixstone-qq

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions