KRL includes a built-in event
module.
The module provides a send
action
(see documentation page “event”).
It has been suggested that an alternate form of event:send
could allow the KRL programmer to specify
a subscription identifier instead of an event channel identifier (ECI).
The setup will be a test pico and two other picos to which it is related by subscription;
the test pico will play the role of "petitioner"
while the other picos will play the role of "responder"
.
A simple setup will look something like this:
Create the test pico, make subscriptions between it and two other picos, and add a new channel for testing purposes.
Have at least one of the picos be hosted by a pico engine running in a different domain and/or port.
This would more fully test the event:send
operations.
But the first test wouldn’t run as written, as the host
argument would need to be known.
First, a regression unit test to ensure that event:send
works as presently constituted.
Then, a TDD test to show that the new form doesn’t work.
This second test can double as a regression test, once the feature has been implemented.
Then, another TDD test to show that passing in the entire subscription map doesn’t work.
This third test doubles as a regression test, once the entire map feature has been implemented.
event:send
petitioner:has_answered
buttonevent:send
test.event_send.eci
ruleset from this repotest.event_send.sub
ruleset$ diff UnitTest/event_send/test.event_send.*
1c1
< ruleset test.event_send.eci {
---
> ruleset test.event_send.sub {
14c14
< event:send({"eci":s{"Tx"},"eid":"none",
---
> event:send({"sub":s{"Id"},"eid":"none",
event:send
test.event_send.sub
rulesettest.event_send.sub_map
ruleset from this repo$ diff UnitTest/event_send/test.event_send.sub*
1c1
< ruleset test.event_send.sub {
---
> ruleset test.event_send.sub_map {
13,14c13,14
< foreach subs:established().filter(resp) setting(s)
< event:send({"sub":s{"Id"},"eid":"none",
---
> foreach subs:established().filter(resp) setting(a_sub)
> event:send({"sub":a_sub,"eid":"none",
16c16
< "attrs":event:attrs},s{"Tx_host"})
---
> "attrs":event:attrs})