Skip to content

Commit 2099296

Browse files
Add cache test
Signed-off-by: Danil-Grigorev <[email protected]>
1 parent 15146bc commit 2099296

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

kube-runtime/src/reflector/dispatcher.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ where
152152
#[cfg(test)]
153153
pub(crate) mod test {
154154
use crate::{
155+
reflector::ObjectRef,
155156
watcher::{Error, Event},
156157
WatchStreamExt,
157158
};
@@ -239,7 +240,7 @@ pub(crate) mod test {
239240
let foo = Arc::new(foo);
240241
let _bar = Arc::new(bar);
241242

242-
let (_, writer) = reflector::store_shared(10);
243+
let (reader, writer) = reflector::store_shared(10);
243244
let mut subscriber = pin!(writer.subscribe().unwrap());
244245
let mut other_subscriber = pin!(writer.subscribe().unwrap());
245246
let mut reflect = pin!(st.reflect_shared(writer));
@@ -249,8 +250,11 @@ pub(crate) mod test {
249250
poll!(reflect.next()),
250251
Poll::Ready(Some(Ok(Event::Delete(_))))
251252
));
253+
assert_eq!(reader.get(&ObjectRef::from_obj(&foo)), Some(foo.clone()));
252254
assert_eq!(poll!(subscriber.next()), Poll::Ready(Some(foo.clone())));
255+
assert_eq!(reader.get(&ObjectRef::from_obj(&foo)), Some(foo.clone()));
253256
assert_eq!(poll!(other_subscriber.next()), Poll::Ready(Some(foo.clone())));
257+
assert_eq!(reader.get(&ObjectRef::from_obj(&foo)), None);
254258

255259
assert!(matches!(
256260
poll!(reflect.next()),

kube-runtime/src/reflector/store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ where
258258
key.extra.remaining_lookups = Some(lookups - 1);
259259
store.insert(key, obj.clone());
260260
}
261-
};
261+
}
262262

263263
obj
264264
})

0 commit comments

Comments
 (0)