fix: fmt
This commit is contained in:
+14
-8
@@ -435,7 +435,7 @@ mod tests {
|
||||
fn test_hostname_format() {
|
||||
// Test that hostname generation produces valid format
|
||||
use std::collections::HashSet;
|
||||
|
||||
|
||||
let mut hostnames = HashSet::new();
|
||||
for _ in 0..100 {
|
||||
let mut hasher = std::collections::hash_map::DefaultHasher::new();
|
||||
@@ -455,24 +455,30 @@ mod tests {
|
||||
.collect();
|
||||
|
||||
let hostname = format!("ecr-test-{}", random_suffix);
|
||||
|
||||
|
||||
// Verify hostname format
|
||||
assert!(hostname.starts_with("ecr-test-"));
|
||||
assert!(hostname.len() > 9); // "ecr-test-" + at least 1 char
|
||||
assert!(hostname.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '-'));
|
||||
|
||||
assert!(hostname
|
||||
.chars()
|
||||
.all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '-'));
|
||||
|
||||
hostnames.insert(hostname);
|
||||
}
|
||||
|
||||
|
||||
// With 100 iterations and good entropy, we should get many unique hostnames
|
||||
assert!(hostnames.len() > 50, "Expected many unique hostnames, got {}", hostnames.len());
|
||||
assert!(
|
||||
hostnames.len() > 50,
|
||||
"Expected many unique hostnames, got {}",
|
||||
hostnames.len()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_set_hostname_uniqueness() {
|
||||
// Verify that rapid consecutive calls produce different hostnames
|
||||
use std::collections::HashSet;
|
||||
|
||||
|
||||
let mut hostnames = Vec::new();
|
||||
for _ in 0..10 {
|
||||
// Simulate the hostname generation logic
|
||||
@@ -494,7 +500,7 @@ mod tests {
|
||||
|
||||
hostnames.push(format!("ecr-test-{}", random_suffix));
|
||||
}
|
||||
|
||||
|
||||
let unique: HashSet<_> = hostnames.iter().collect();
|
||||
// Most hostnames should be unique (high entropy)
|
||||
assert!(unique.len() >= 8, "Expected mostly unique hostnames");
|
||||
|
||||
Reference in New Issue
Block a user