Skip to content

Commit

Permalink
test: update contrtact tests to wait for log entries
Browse files Browse the repository at this point in the history
  • Loading branch information
parfeon committed Jan 25, 2024
1 parent b718ec5 commit 455fd3a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tests/common/common_steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,13 @@ impl Default for PubNubWorld {

impl PubNubWorld {
pub async fn reset(&mut self) {
// self.subscription = None;
self.retry_policy = None;
if let Some(pubnub) = self.pubnub.as_ref() {
log::debug!("Terminate PubNub instance");
pubnub.terminate();
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
}
self.subscription = None;
self.pubnub = None;
}

Expand Down
5 changes: 3 additions & 2 deletions tests/presence/presence_steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use pubnub::subscribe::{

/// Extract list of events and invocations from log.
fn events_and_invocations_history() -> Vec<Vec<String>> {
log::logger().flush();
let mut lines: Vec<Vec<String>> = Vec::new();
let written_log =
read_to_string("tests/logs/log.txt").expect("Unable to read history from log");
Expand Down Expand Up @@ -188,7 +189,7 @@ async fn wait_presence_join(world: &mut PubNubWorld) {

#[then("I receive an error in my heartbeat response")]
async fn receive_an_error_heartbeat_retry(world: &mut PubNubWorld) {
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
tokio::time::sleep(tokio::time::Duration::from_secs(4)).await;

let history = events_and_invocations_history();
let expected_retry_count: usize = usize::from(match &world.retry_policy.clone().unwrap() {
Expand All @@ -208,7 +209,7 @@ async fn receive_an_error_heartbeat_retry(world: &mut PubNubWorld) {
}

#[then("I don't observe any Events and Invocations of the Presence EE")]
async fn event_engine_history_empty(_world: &mut PubNubWorld, _step: &Step) {
async fn event_engine_history_empty(_world: &mut PubNubWorld) {
assert_eq!(events_and_invocations_history().len(), 0);
}

Expand Down

0 comments on commit 455fd3a

Please sign in to comment.