Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
  • Loading branch information
bnjjj committed Nov 6, 2024
1 parent 898f156 commit 9065a18
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apollo-router/src/plugins/cache/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ pub(crate) struct CacheKeyContext {
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(test, derive(PartialEq, Eq, Hash, Ord))]
#[cfg_attr(test, derive(PartialEq, Eq, Hash))]
#[serde(rename_all = "snake_case")]
pub(crate) enum CacheKeyStatus {
/// New cache key inserted in the cache
Expand All @@ -1598,12 +1598,18 @@ pub(crate) enum CacheKeyStatus {
#[cfg(test)]
impl PartialOrd for CacheKeyStatus {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}

#[cfg(test)]
impl Ord for CacheKeyStatus {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
match (self, other) {
(CacheKeyStatus::New, CacheKeyStatus::New) => std::cmp::Ordering::Equal,
(CacheKeyStatus::New, CacheKeyStatus::Cached) => std::cmp::Ordering::Greater,
(CacheKeyStatus::Cached, CacheKeyStatus::New) => std::cmp::Ordering::Less,
(CacheKeyStatus::Cached, CacheKeyStatus::Cached) => std::cmp::Ordering::Equal,
}
.into()
}
}

0 comments on commit 9065a18

Please sign in to comment.