At 2014-06-13 04:00:08 -0700, [email protected] wrote:
>
> Right now, I use *Mojo::IOLoop->timer* to arbitrarily wait for some
> time before doing the assertion

I agree, that's not a very good approach.

Since you'll be checking the contents of an external system (redis) in
your test, I see no alternative to asking the server if it's finished
what it was doing or not.

You could, for example, expose a new route like this:

    $r->route('/testwait')->to(cb => sub {
        wait_for_something_in_redis_to_become_1();
        shift->render(text => "ok, go ahead");
    });

Then you call set_something_in_redis_to(0) before you fire off your
callback that does whatever you want to test, and end the callback by
calling set_something_in_redis_to(1).

Then in your test, you make a request to /testwait and when it returns,
you know that you can ask Redis for the value you expect.

-- ams

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to