Skip to content

producer/consumer: ability to mock for tests #182

@jchauncey

Description

@jchauncey

Would be awesome if there was some way to create a mock producer/consumer that acted like it was actually interacting with a real nsq instance.

Activity

jchauncey

jchauncey commented on Jun 13, 2016

@jchauncey
Author

Basically I'd like to have some of these methods made public - https://github.com/nsqio/go-nsq/blob/master/mock_test.go

jehiah

jehiah commented on Jun 13, 2016

@jehiah
Member

@jchauncey I'm not sure how i feel about exposing an interface in go-nsq for testing, but I've used this to much success https://gist.github.com/jehiah/572be9b20c55e5ebbd2d21c73da5b08e It might be sufficient for your needs too. The included NoOpMessageDelegate can make it easier to construct nsq.Message for calling a handler directly to test consumers.

jchauncey

jchauncey commented on Jun 21, 2016

@jchauncey
Author

So what i wanted to do was test the consumption of a mock message in an app I was writing without having to actually start nsq. I ended up copying a lot of the functions in mock_test to get it to work but that seemed rather clunky.

changed the title [-]Ability to mock producer/consumer interaction[/-] [+]producer/consumer: ability to mock for tests[/+] on Jun 25, 2016
mreiferson

mreiferson commented on Jun 25, 2016

@mreiferson
Member

The code in mock_test feels like too much to be exporting, mostly because it's designed to validate low level protocol behaviors.

I feel like what you want could be much simpler, and depending on what we came up with I think we could at least consider providing as a set of exported types in go-nsq.

Are you interested in taking a pass?

mreiferson

mreiferson commented on Apr 16, 2017

@mreiferson
Member

See #146

sefasenturk95

sefasenturk95 commented on Mar 7, 2018

@sefasenturk95

Is it still not possible to mock NSQ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jehiah@mreiferson@jchauncey@sefasenturk95

        Issue actions

          producer/consumer: ability to mock for tests · Issue #182 · nsqio/go-nsq