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
I have used the lib in a use case when several events are sent to EventBridge, I thought that the getEvents method would fetch them all (until the queue was empty). But instead, it only fetched the messages one by one. This was quite confusing since the plural in the name of the method lead me to think it would fetch all the events fired so far. This confusion caused many failure in my test suite, which were difficult to debug.
So, in the end, I implemented a method like so to fetch all events in one function call:
staticasyncgetAllEventBridgeMessages(): Promise<EventBridgeMessage[]>{if(EventBridgeTestUtil.eventBridge===null){thrownewError("EventBridgeTestUtil has not been setup");}letresult: EventBridgeMessage[]=[];letlastResults: EventBridgeMessage[]=[];do{try{constevents=awaitEventBridgeTestUtil.eventBridge.getEvents();lastResults=events.Messages;result=[...result, ...lastResults];}catch(e){lastResults=[];}}while(lastResults.length!==0);returnresult;}
It would be great if getEvents could be renamed to be clearer, such as getEvent and if a method getAllEvents could be implemented :)
Thanks ;)
The text was updated successfully, but these errors were encountered:
Hi :)
I have used the lib in a use case when several events are sent to EventBridge, I thought that the getEvents method would fetch them all (until the queue was empty). But instead, it only fetched the messages one by one. This was quite confusing since the plural in the name of the method lead me to think it would fetch all the events fired so far. This confusion caused many failure in my test suite, which were difficult to debug.
So, in the end, I implemented a method like so to fetch all events in one function call:
It would be great if
getEvents
could be renamed to be clearer, such asgetEvent
and if a methodgetAllEvents
could be implemented :)Thanks ;)
The text was updated successfully, but these errors were encountered: