Skip to content

Commit

Permalink
Add cache test
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <[email protected]>
  • Loading branch information
Danil-Grigorev committed Dec 29, 2024
1 parent ae58140 commit 61a9766
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions kube-runtime/src/reflector/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ where
#[cfg(test)]
pub(crate) mod test {
use crate::{
watcher::{Error, Event},
WatchStreamExt,
reflector::ObjectRef, watcher::{Error, Event}, WatchStreamExt
};
use std::{pin::pin, sync::Arc, task::Poll};

Expand Down Expand Up @@ -239,7 +238,7 @@ pub(crate) mod test {
let foo = Arc::new(foo);
let _bar = Arc::new(bar);

let (_, writer) = reflector::store_shared(10);
let (reader, writer) = reflector::store_shared(10);
let mut subscriber = pin!(writer.subscribe().unwrap());
let mut other_subscriber = pin!(writer.subscribe().unwrap());
let mut reflect = pin!(st.reflect_shared(writer));
Expand All @@ -249,8 +248,11 @@ pub(crate) mod test {
poll!(reflect.next()),
Poll::Ready(Some(Ok(Event::Delete(_))))
));
assert_eq!(reader.get(&ObjectRef::from_obj(&foo)), Some(foo.clone()));
assert_eq!(poll!(subscriber.next()), Poll::Ready(Some(foo.clone())));
assert_eq!(reader.get(&ObjectRef::from_obj(&foo)), Some(foo.clone()));
assert_eq!(poll!(other_subscriber.next()), Poll::Ready(Some(foo.clone())));
assert_eq!(reader.get(&ObjectRef::from_obj(&foo)), None);

assert!(matches!(
poll!(reflect.next()),
Expand Down

0 comments on commit 61a9766

Please sign in to comment.