Print RepoId as a number in tests

We are not going to generate repository ids randomly, so we can
take advantage of that and print a nicer representation of
the repository id.

Co-Authored-By: Julia Risley <julia@zed.dev>
This commit is contained in:
Antonio Scandurra
2023-07-25 15:33:14 +02:00
parent cbdb83fb43
commit 369d85b82e

View File

@@ -33,9 +33,7 @@ mod btree {
pub use sum_tree::{SumTree as Sequence, TreeMap as Map, TreeSet as Set, *};
}
#[derive(
Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
)]
#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct RepoId(Uuid);
impl RepoId {
@@ -54,7 +52,21 @@ impl RepoId {
impl Display for RepoId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0.as_hyphenated())
#[cfg(not(any(test, feature = "test-support")))]
return write!(f, "{}", self.0.as_hyphenated());
#[cfg(any(test, feature = "test-support"))]
return write!(f, "{}", self.0.as_u128());
}
}
impl Debug for RepoId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[cfg(not(any(test, feature = "test-support")))]
return write!(f, "RepoId({})", self.0.as_hyphenated());
#[cfg(any(test, feature = "test-support"))]
return write!(f, "RepoId({})", self.0.as_u128());
}
}
@@ -2179,7 +2191,7 @@ mod tests {
Self::PublishRepo {
client_id,
id: repo.id,
name: repo.id.to_string().into(),
name: format!("repo-{}", repo.id).into(),
}
} else if branches.is_empty() || rng.gen_bool(0.1) {
Self::CreateEmptyBranch {