Skip to content

Commit

Permalink
Use deterministic Uuids in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ab22593k committed Jan 13, 2025
1 parent 818e55a commit 853ec46
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ rust-version = "1.63.0"
rustc-args = ["--cfg", "uuid_unstable"]
rustdoc-args = ["--cfg", "uuid_unstable"]
targets = ["x86_64-unknown-linux-gnu"]
features = ["serde", "arbitrary", "slog", "borsh", "nonzero", "v1", "v3", "v4", "v5", "v6", "v7", "v8"]
features = ["serde", "arbitrary", "slog", "borsh", "v1", "v3", "v4", "v5", "v6", "v7", "v8"]

[package.metadata.playground]
features = ["serde", "v1", "v3", "v4", "v5", "v6", "v7", "v8"]
Expand Down
8 changes: 4 additions & 4 deletions src/non_nil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl From<NonNilUuid> for Uuid {
/// ```
/// use uuid::{non_nil::NonNilUuid, Uuid};
///
/// let uuid = Uuid::new_v4();
/// let uuid = Uuid::from_u128(0x0123456789abcdef0123456789abcdef);
/// let non_nil = NonNilUuid::from(uuid);
/// let uuid_again = Uuid::from(non_nil);
///
Expand All @@ -46,7 +46,7 @@ impl From<Uuid> for NonNilUuid {
/// ```
/// use uuid::{non_nil::NonNilUuid, Uuid};
///
/// let uuid = Uuid::new_v4();
/// let uuid = Uuid::from_u128(0x0123456789abcdef0123456789abcdef);
/// let non_nil = NonNilUuid::from(uuid);
/// ```
fn from(uuid: Uuid) -> Self {
Expand All @@ -70,15 +70,15 @@ mod tests {

#[test]
fn test_new_with_non_nil() {
let uuid = Uuid::new_v4();
let uuid = Uuid::from_u128(0x0123456789abcdef0123456789abcdef);
let nn_uuid = NonNilUuid::from(uuid);
assert_eq!(Uuid::from(nn_uuid), uuid);
}

#[test]
#[should_panic(expected = "Attempted to convert nil Uuid to NonNilUuid")]
fn test_new_with_nil() {
let nil_uuid = Uuid::nil();
let nil_uuid = Uuid::from_u128(0x0);
let _ = NonNilUuid::from(nil_uuid);
}
}

0 comments on commit 853ec46

Please sign in to comment.