Skip to content

Commit a803a75

Browse files
committed
Move test_cratesio_hash into test mod
1 parent c994a4a commit a803a75

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

src/cargo/core/source/source_id.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -681,31 +681,6 @@ impl Ord for SourceKind {
681681
}
682682
}
683683

684-
// This is a test that the hash of the `SourceId` for crates.io is a well-known
685-
// value.
686-
//
687-
// Note that the hash value matches what the crates.io source id has hashed
688-
// since long before Rust 1.30. We strive to keep this value the same across
689-
// versions of Cargo because changing it means that users will need to
690-
// redownload the index and all crates they use when using a new Cargo version.
691-
//
692-
// This isn't to say that this hash can *never* change, only that when changing
693-
// this it should be explicitly done. If this hash changes accidentally and
694-
// you're able to restore the hash to its original value, please do so!
695-
// Otherwise please just leave a comment in your PR as to why the hash value is
696-
// changing and why the old value can't be easily preserved.
697-
//
698-
// The hash value depends on endianness and bit-width, so we only run this test on
699-
// little-endian 64-bit CPUs (such as x86-64 and ARM64) where it matches the
700-
// well-known value.
701-
#[test]
702-
#[cfg(all(target_endian = "little", target_pointer_width = "64"))]
703-
fn test_cratesio_hash() {
704-
let config = Config::default().unwrap();
705-
let crates_io = SourceId::crates_io(&config).unwrap();
706-
assert_eq!(crate::util::hex::short_hash(&crates_io), "1ecc6299db9ec823");
707-
}
708-
709684
/// A `Display`able view into a `SourceId` that will write it as a url
710685
pub struct SourceIdAsUrl<'a> {
711686
inner: &'a SourceIdInner,
@@ -792,7 +767,7 @@ impl<'a> fmt::Display for PrettyRef<'a> {
792767
#[cfg(test)]
793768
mod tests {
794769
use super::{GitReference, SourceId, SourceKind};
795-
use crate::util::IntoUrl;
770+
use crate::util::{Config, IntoUrl};
796771

797772
#[test]
798773
fn github_sources_equal() {
@@ -809,4 +784,29 @@ mod tests {
809784
let s3 = SourceId::new(foo, loc, None).unwrap();
810785
assert_ne!(s1, s3);
811786
}
787+
788+
// This is a test that the hash of the `SourceId` for crates.io is a well-known
789+
// value.
790+
//
791+
// Note that the hash value matches what the crates.io source id has hashed
792+
// since long before Rust 1.30. We strive to keep this value the same across
793+
// versions of Cargo because changing it means that users will need to
794+
// redownload the index and all crates they use when using a new Cargo version.
795+
//
796+
// This isn't to say that this hash can *never* change, only that when changing
797+
// this it should be explicitly done. If this hash changes accidentally and
798+
// you're able to restore the hash to its original value, please do so!
799+
// Otherwise please just leave a comment in your PR as to why the hash value is
800+
// changing and why the old value can't be easily preserved.
801+
//
802+
// The hash value depends on endianness and bit-width, so we only run this test on
803+
// little-endian 64-bit CPUs (such as x86-64 and ARM64) where it matches the
804+
// well-known value.
805+
#[test]
806+
#[cfg(all(target_endian = "little", target_pointer_width = "64"))]
807+
fn test_cratesio_hash() {
808+
let config = Config::default().unwrap();
809+
let crates_io = SourceId::crates_io(&config).unwrap();
810+
assert_eq!(crate::util::hex::short_hash(&crates_io), "1ecc6299db9ec823");
811+
}
812812
}

0 commit comments

Comments
 (0)