You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How do I test callbacks/delegates which are not triggered
immediately? Especially when I need to do unit tests with an
event loop?
A simple example from my codebase (SaaSy here is a custom HTTP
client to an API endpoint):
class TestSaaSy {
mixin TestMixin;
// this works
void test_encoded_auth() {
auto ev = new EventLoop;
auto saasy = new SaaSy(ev, "test", "test");
assert(saasy.encoded_auth == "dGVzdDp0ZXN0dGVzdA==", "encoding issue");
ev.close;
ev.run;
}
// won't work. test gets finished even before the callback is fired!
void test_get_subscription() {
auto ev = new EventLoop;
auto saasy = new SaaSy(ev, "test", "test");
saasy.getSubscription("ref363466", (bool err, string response) {
assert(err == true);
ev.close;
});
ev.run;
}
}
How do I test callbacks/delegates which are not triggered
immediately? Especially when I need to do unit tests with an
event loop?
A simple example from my codebase (SaaSy here is a custom HTTP
client to an API endpoint):
Discussion in D forum: http://forum.dlang.org/thread/[email protected]?page=2
The text was updated successfully, but these errors were encountered: