Skip to content

Commit

Permalink
test(coverage): add test for default backoff
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>
  • Loading branch information
tiagolobocastro committed Oct 14, 2024
1 parent 6603b42 commit fd3d1c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kube-runtime/src/utils/backoff_reset_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,10 @@ mod tests {
tokio::time::Instant::now().into_std()
}
}

impl<B: Backoff> ResetTimerBackoff<B> {
pub fn get_backoff(&self) -> &B {
&self.backoff
}
}
}
10 changes: 10 additions & 0 deletions kube-runtime/src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,3 +919,13 @@ impl Backoff for DefaultBackoff {
self.0.reset()
}
}

#[cfg(test)]
mod tests {
#[test]
fn backoff_start_interval() {
let default_backoff = super::DefaultBackoff::default().0;
let default_backoff = default_backoff.get_backoff();
assert_eq!(default_backoff.current_interval, default_backoff.initial_interval);
}
}

0 comments on commit fd3d1c2

Please sign in to comment.