Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support testing one robot (shared brain) present in multiple rooms #32

Open
MatthewMazaika opened this issue May 27, 2016 · 7 comments
Open

Comments

@MatthewMazaika
Copy link

not sure about other implementations, but in slack, hubot can be in multiple rooms (channels), but there is only one instance of the robot and brain

is there a way to test this functionality with the current test-helper and I'm missing it?

if not, can we add on this functionality? i'd be glad to implement and PR with some guidance, but at this point I don't quite have a lot of background on test-helper or hubot architecture.

thanks!
Matt

@mtsmfm
Copy link
Owner

mtsmfm commented Aug 17, 2016

@MatthewMazaika

At this time, there is no way to share brain 😢
But I wonder why do you want to share the brain 💫
Could you tell me the context and ideal test code? (the code won't work at the time but I want to know how do you want to write test 😉 )

@IAmPatrickB
Copy link

This is something I do as well, but I haven't written tests for my custom scripts yet - in an Enterprise level organization, we have hundreds of rooms our Hubot is in. I've written a few custom scripts to support Authentication based on level of user in a Room, the room a user is in, or the room a request comes from. Ours also provides the ability to message users across rooms by mentioning a nick that's designated to the hubot "i.e. @hubot this room belongs to Perf", then anyone who mentions @Perf the bot will transmit the message to their private room.

I'm looking at implementing some custom test scripts this week, I'll let you know what challenges I run into.

@timkinnane
Copy link

Would also like to do this. I'm testing scripts for a platform with many rooms, where use cases need hubot to remember past interactions and context with a user across rooms. Ran into a wall trying to test some uncommon behaviour for fairly specific interactions. e.g. it should respond to a given user in any room, but not other users - or - it will respond to any user in a given room, but not other rooms.

I have similar requirements to this example from Hubot-Conversation but would prefer to find an approach consistent with my other tests using hubot-test-helper.

e.g.

@room1 = helper.createRoom name: 'room1'
@room2 = helper.createRoom name: 'room2'
@room1.user.say 'user1', 'hello its me'
@room2.user.say 'user1', 'its me again'

I discovered one easy tip for anyone trying this, that the httpd: false option will prevent EADDRINUSE 0.0.0.0:8080 errors from trying to setup multiple concurrent listeners.

@yozlet
Copy link

yozlet commented Apr 25, 2017

Here's a really simple test case: I have a hubot script which can be triggered in any room that the bot is in, and the result is that it should emit a message to a configured target room.

Here's the script: https://github.com/18F/18f-bot/blob/master/scripts/love.coffee
Here's the test case I wrote: https://github.com/18F/18f-bot/blob/master/test/scripts/love_test.coffee

However, this test case only works because hubot-test-helper doesn't differentiate between rooms in which the message is being emitted. Ideally, the test case should involve two rooms, emit the trigger message in the first room, and assert that the result message is emitted in the second room.

EDITED TO ADD: @timkinnane, I only just noticed hubot-pretend. Nice! I'll try rewriting the test with that when I get a moment.

@timkinnane
Copy link

@yozlet - Cool! You'll be the first user afaik. I think it's pretty good and have used it extensively in my own project. I tried to write clear and comprehensive tests, but I'd be really interested to get your feedback - it's easy to miss things when you're the creator and only user.

Have a look here for multi-room test examples.

paroxp added a commit to paroxp/robotk that referenced this issue Dec 22, 2017
We'd like to go forward with the confidence of application keep on
working. Ideal situation would be to hold a set of tests, covering each
line of code in our system. This however proves to be difficult for
different reasons.

For instance, I'd like to test that `lit` command when successful would
create a message in a separate channel. Sounds simple, yet the hubot
testing helper does not support the functionality of multiple rooms.
This issue has already been raised with upstream [1] and needs yet to be
resolved.

In order to keep hubot happy, I had to separate the script tests into a
separate directory. In fact, two of them, as I've separated the response
messages from script file, to be DRY about it when using in tests. The
`.messages.js` file is obsolete and _should_ be removed once we come out
with ideal configuration system.

I took the lousy approach of implementing tests for the other functions.
I'm sorry.

[1] mtsmfm/hubot-test-helper#32
paroxp added a commit to paroxp/robotk that referenced this issue Dec 22, 2017
We'd like to go forward with the confidence of application keep on
working. Ideal situation would be to hold a set of tests, covering each
line of code in our system. This however proves to be difficult for
different reasons.

For instance, I'd like to test that `lit` command when successful would
create a message in a separate channel. Sounds simple, yet the hubot
testing helper does not support the functionality of multiple rooms.
This issue has already been raised with upstream [1] and needs yet to be
resolved.

In order to keep hubot happy, I had to separate the script tests into a
separate directory. In fact, two of them, as I've separated the response
messages from script file, to be DRY about it when using in tests. The
`.messages.js` file is obsolete and _should_ be removed once we come out
with ideal configuration system.

I took the lousy approach of implementing tests for the other functions.
I'm sorry.

[1] mtsmfm/hubot-test-helper#32
paroxp added a commit to paroxp/robotk that referenced this issue Dec 23, 2017
We'd like to go forward with the confidence of application keep on
working. Ideal situation would be to hold a set of tests, covering each
line of code in our system. This however proves to be difficult for
different reasons.

For instance, I'd like to test that `lit` command when successful would
create a message in a separate channel. Sounds simple, yet the hubot
testing helper does not support the functionality of multiple rooms.
This issue has already been raised with upstream [1] and needs yet to be
resolved.

In order to keep hubot happy, I had to separate the script tests into a
separate directory. In fact, two of them, as I've separated the response
messages from script file, to be DRY about it when using in tests. The
`.messages.js` file is obsolete and _should_ be removed once we come out
with ideal configuration system.

I took the lousy approach of implementing tests for the other functions.
I'm sorry.

[1] mtsmfm/hubot-test-helper#32
paroxp added a commit to paroxp/robotk that referenced this issue Dec 23, 2017
We'd like to go forward with the confidence of application keep on
working. Ideal situation would be to hold a set of tests, covering each
line of code in our system. This however proves to be difficult for
different reasons.

For instance, I'd like to test that `lit` command when successful would
create a message in a separate channel. Sounds simple, yet the hubot
testing helper does not support the functionality of multiple rooms.
This issue has already been raised with upstream [1] and needs yet to be
resolved.

In order to keep hubot happy, I had to separate the script tests into a
separate directory. In fact, two of them, as I've separated the response
messages from script file, to be DRY about it when using in tests. The
`.messages.js` file is obsolete and _should_ be removed once we come out
with ideal configuration system.

I took the lousy approach of implementing tests for the other functions.
I'm sorry.

[1] mtsmfm/hubot-test-helper#32
paroxp added a commit to paroxp/robotk that referenced this issue Jan 17, 2018
We'd like to go forward with the confidence of application keep on
working. Ideal situation would be to hold a set of tests, covering each
line of code in our system. This however proves to be difficult for
different reasons.

For instance, I'd like to test that `lit` command when successful would
create a message in a separate channel. Sounds simple, yet the hubot
testing helper does not support the functionality of multiple rooms.
This issue has already been raised with upstream [1] and needs yet to be
resolved.

In order to keep hubot happy, I had to separate the script tests into a
separate directory. In fact, two of them, as I've separated the response
messages from script file, to be DRY about it when using in tests. The
`.messages.js` file is obsolete and _should_ be removed once we come out
with ideal configuration system.

I took the lousy approach of implementing tests for the other functions.
I'm sorry.

[1] mtsmfm/hubot-test-helper#32
@ummaycoc
Copy link

Did anything come of this?

@timkinnane
Copy link

@ummaycoc I'm working on a new framework of the whole stack I developed based on hubot, nubot/playbook/pretend - it will provide multi room testing tools, but is still a little way off. If you'd like to get early access please email me: timkinnane@gmail.com

For now, here's the updated link from above, for using Pretend to do multi-room tests...

https://github.com/timkinnane/hubot-pretend/blob/master/test/usage/02-rooms_test.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants