Skip to content

Commit 1e5ff84

Browse files
committed
refactor: migrate ulid constructors to r#gen
1 parent 074c2ad commit 1e5ff84

15 files changed

Lines changed: 114 additions & 86 deletions

api/src/routes/metadata.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2946,8 +2946,8 @@ mod tests {
29462946
async fn setup_search_pagination_cluster(node_count: usize) -> SearchPaginationCluster {
29472947
let realm_signing_key = test_realm_signing_key();
29482948
let realm_id = RealmId::from_bytes(realm_signing_key.verifying_key().to_bytes());
2949-
let user_id = aruna_core::UserId::local(Ulid::new(), realm_id);
2950-
let group_id = Ulid::new();
2949+
let user_id = aruna_core::UserId::local(Ulid::r#gen(), realm_id);
2950+
let group_id = Ulid::r#gen();
29512951

29522952
let mut nodes = Vec::new();
29532953
for _ in 0..node_count {
@@ -3967,7 +3967,7 @@ mod tests {
39673967
.await
39683968
.unwrap();
39693969
let node_id = net.node_id();
3970-
let user_id = aruna_core::UserId::local(Ulid::new(), realm_id);
3970+
let user_id = aruna_core::UserId::local(Ulid::r#gen(), realm_id);
39713971
let actor = Actor {
39723972
node_id,
39733973
user_id,
@@ -4007,7 +4007,7 @@ mod tests {
40074007
.into(),
40084008
)
40094009
.await;
4010-
let group_id = Ulid::new();
4010+
let group_id = Ulid::r#gen();
40114011
let group_auth =
40124012
GroupAuthorizationDocument::new_default_group_doc(user_id, realm_id, group_id);
40134013
let group = Group {

api/src/s3/s3_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2765,7 +2765,7 @@ mod tests {
27652765
None
27662766
);
27672767

2768-
let marker = Ulid::new();
2768+
let marker = Ulid::r#gen();
27692769
assert_eq!(
27702770
parse_upload_id_marker(Some("key"), Some(&marker.to_string())).unwrap(),
27712771
Some(marker)

core/src/structs/blob.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,8 @@ mod tests {
653653
let now = SystemTime::now();
654654
let base = UserAccess {
655655
access_key: "access".into(),
656-
user_identity: UserId::local(Ulid::new(), RealmId::from_bytes([1u8; 32])),
657-
group_id: Ulid::new(),
656+
user_identity: UserId::local(Ulid::r#gen(), RealmId::from_bytes([1u8; 32])),
657+
group_id: Ulid::r#gen(),
658658
secret: "secret".into(),
659659
expiry: now + Duration::from_secs(60),
660660
path_restrictions: None,

core/src/structs/multipart.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ mod test {
217217
// Prefix keeps the whole version id, spans all part numbers, excludes the summary.
218218
#[test]
219219
fn prefix_covers_version() {
220-
let version_id = Ulid::new();
220+
let version_id = Ulid::r#gen();
221221
let prefix = MultipartObjectMetadataKey::part_prefix(version_id).unwrap();
222222

223223
// The prefix must be the part key with the fixed part-number suffix stripped.
@@ -244,7 +244,7 @@ mod test {
244244
assert!(!summary_key.starts_with(&prefix));
245245

246246
// A different version must not be captured by this version's prefix.
247-
let other_key = MultipartObjectMetadataKey::part(Ulid::new(), 0)
247+
let other_key = MultipartObjectMetadataKey::part(Ulid::r#gen(), 0)
248248
.to_bytes()
249249
.unwrap();
250250
assert!(!other_key.starts_with(&prefix));

operations/src/s3/copy_object.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ mod test {
286286
data: &'static [u8],
287287
) -> PutObjectConfig {
288288
PutObjectConfig {
289-
user_id: UserId::local(Ulid::new(), realm_id),
289+
user_id: UserId::local(Ulid::r#gen(), realm_id),
290290
group_id,
291291
realm_id,
292292
node_id,
@@ -305,7 +305,7 @@ mod test {
305305
}
306306

307307
async fn write_version(context: &DriverContext, bucket: &str, key: &str, version: BlobVersion) {
308-
let version_id = Ulid::new();
308+
let version_id = Ulid::r#gen();
309309
let Event::Storage(StorageEvent::TransactionStarted { txn_id }) = context
310310
.storage_handle
311311
.send_storage_effect(StorageEffect::StartTransaction { read: false })
@@ -370,7 +370,7 @@ mod test {
370370
async fn materialized_copy_dedups_source_blob() {
371371
let (_temp, context) = full_context().await;
372372
let realm_id = RealmId::from_bytes([1u8; 32]);
373-
let group_id = Ulid::new();
373+
let group_id = Ulid::r#gen();
374374
let node_id = context.net_handle.as_ref().unwrap().node_id();
375375

376376
let source = drive(
@@ -402,7 +402,7 @@ mod test {
402402
source_group_id: group_id,
403403
dest_bucket: "bucket".to_string(),
404404
dest_key: "dest.txt".to_string(),
405-
user_id: UserId::local(Ulid::new(), realm_id),
405+
user_id: UserId::local(Ulid::r#gen(), realm_id),
406406
group_id,
407407
realm_id,
408408
node_id,
@@ -436,7 +436,7 @@ mod test {
436436
async fn reference_copy_materializes_bytes_with_snapshot_binding() {
437437
let (_temp, context) = full_context().await;
438438
let realm_id = RealmId::from_bytes([2u8; 32]);
439-
let group_id = Ulid::new();
439+
let group_id = Ulid::r#gen();
440440
let node_id = context.net_handle.as_ref().unwrap().node_id();
441441

442442
let (endpoint, server) = spawn_reference_server(b"reference-bytes").await;
@@ -450,7 +450,7 @@ mod test {
450450
capabilities: Vec::new(),
451451
origin_node_id: None,
452452
},
453-
connector_id: Some(Ulid::new()),
453+
connector_id: Some(Ulid::r#gen()),
454454
};
455455
write_version(
456456
&context,
@@ -466,7 +466,7 @@ mod test {
466466
source_version: None,
467467
},
468468
SystemTime::UNIX_EPOCH,
469-
UserId::local(Ulid::new(), realm_id),
469+
UserId::local(Ulid::r#gen(), realm_id),
470470
SystemTime::UNIX_EPOCH,
471471
),
472472
)
@@ -481,7 +481,7 @@ mod test {
481481
source_group_id: group_id,
482482
dest_bucket: "bucket".to_string(),
483483
dest_key: "dest.txt".to_string(),
484-
user_id: UserId::local(Ulid::new(), realm_id),
484+
user_id: UserId::local(Ulid::r#gen(), realm_id),
485485
group_id,
486486
realm_id,
487487
node_id,
@@ -512,7 +512,7 @@ mod test {
512512
version_id: None,
513513
range: None,
514514
group_id,
515-
user_identity: UserId::local(Ulid::new(), realm_id),
515+
user_identity: UserId::local(Ulid::r#gen(), realm_id),
516516
}),
517517
&context,
518518
)
@@ -532,10 +532,10 @@ mod test {
532532
async fn delete_marker_source_errors() {
533533
let (_temp, context) = full_context().await;
534534
let realm_id = RealmId::from_bytes([3u8; 32]);
535-
let group_id = Ulid::new();
535+
let group_id = Ulid::r#gen();
536536
let node_id = context.net_handle.as_ref().unwrap().node_id();
537537

538-
let version_id = Ulid::new();
538+
let version_id = Ulid::r#gen();
539539
let Event::Storage(StorageEvent::TransactionStarted { txn_id }) = context
540540
.storage_handle
541541
.send_storage_effect(StorageEffect::StartTransaction { read: false })
@@ -553,7 +553,7 @@ mod test {
553553
.into(),
554554
value: BlobVersion::deleted(
555555
SystemTime::now(),
556-
UserId::local(Ulid::new(), realm_id),
556+
UserId::local(Ulid::r#gen(), realm_id),
557557
)
558558
.to_bytes()
559559
.unwrap()
@@ -575,7 +575,7 @@ mod test {
575575
source_group_id: group_id,
576576
dest_bucket: "bucket".to_string(),
577577
dest_key: "dest.txt".to_string(),
578-
user_id: UserId::local(Ulid::new(), realm_id),
578+
user_id: UserId::local(Ulid::r#gen(), realm_id),
579579
group_id,
580580
realm_id,
581581
node_id,
@@ -688,7 +688,7 @@ mod test {
688688
async fn precondition_failure_leaves_no_new_version() {
689689
let (_temp, context) = full_context().await;
690690
let realm_id = RealmId::from_bytes([4u8; 32]);
691-
let group_id = Ulid::new();
691+
let group_id = Ulid::r#gen();
692692
let node_id = context.net_handle.as_ref().unwrap().node_id();
693693

694694
drive(
@@ -716,7 +716,7 @@ mod test {
716716
source_group_id: group_id,
717717
dest_bucket: "bucket".to_string(),
718718
dest_key: "dest.txt".to_string(),
719-
user_id: UserId::local(Ulid::new(), realm_id),
719+
user_id: UserId::local(Ulid::r#gen(), realm_id),
720720
group_id,
721721
realm_id,
722722
node_id,

operations/src/s3/create_bucket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ mod test {
300300
};
301301

302302
let bucket_info = BucketInfo {
303-
group_id: Ulid::new(),
303+
group_id: Ulid::r#gen(),
304304
created_at: SystemTime::now(),
305305
created_by: Default::default(),
306306
cors_configuration: None,

operations/src/s3/delete_object.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,8 +1057,8 @@ mod test {
10571057
DeleteObjectOperation::new(DeleteObjectInput {
10581058
bucket: "mybucket".to_string(),
10591059
key: "missing.txt".to_string(),
1060-
version_id: Some(Ulid::new()),
1061-
group_id: Ulid::new(),
1060+
version_id: Some(Ulid::r#gen()),
1061+
group_id: Ulid::r#gen(),
10621062
realm_id: RealmId::from_bytes([1u8; 32]),
10631063
node_id: iroh::SecretKey::generate().public(),
10641064
deleted_by: test_user_id(),

operations/src/s3/delete_objects.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ mod test {
150150
async fn delete_objects_processes_mixed_batch() {
151151
let (_temp, context) = test_context().await;
152152
let realm_id = RealmId::from_bytes([1u8; 32]);
153-
let user_id = UserId::local(Ulid::new(), realm_id);
154-
let group_id = Ulid::new();
153+
let user_id = UserId::local(Ulid::r#gen(), realm_id);
154+
let group_id = Ulid::r#gen();
155155
let node_id = context.net_handle.as_ref().unwrap().node_id();
156156
seed_object(
157157
&context,
@@ -164,7 +164,7 @@ mod test {
164164
)
165165
.await;
166166

167-
let missing_version = Ulid::new();
167+
let missing_version = Ulid::r#gen();
168168
let outcomes = delete_objects(
169169
&context,
170170
DeleteObjectsInput {
@@ -211,8 +211,8 @@ mod test {
211211
async fn delete_objects_isolates_failures() {
212212
let (_temp, context) = test_context().await;
213213
let realm_id = RealmId::from_bytes([1u8; 32]);
214-
let user_id = UserId::local(Ulid::new(), realm_id);
215-
let group_id = Ulid::new();
214+
let user_id = UserId::local(Ulid::r#gen(), realm_id);
215+
let group_id = Ulid::r#gen();
216216
let node_id = context.net_handle.as_ref().unwrap().node_id();
217217
seed_object(
218218
&context, "mybucket", "keep.txt", user_id, group_id, realm_id, node_id,
@@ -226,7 +226,7 @@ mod test {
226226
entries: vec![
227227
DeleteObjectsEntry {
228228
key: "keep.txt".to_string(),
229-
version_id: Some(Ulid::new()),
229+
version_id: Some(Ulid::r#gen()),
230230
},
231231
DeleteObjectsEntry {
232232
key: "keep.txt".to_string(),

operations/src/s3/get_object_attributes.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,11 @@ mod tests {
490490
root: "/tmp".to_string(),
491491
storage_bucket: "mybucket".to_string(),
492492
backend_path: "hello.txt".to_string(),
493-
ulid: Ulid::new(),
493+
ulid: Ulid::r#gen(),
494494
compressed: false,
495495
encrypted: false,
496496
created_at: SystemTime::UNIX_EPOCH,
497-
created_by: UserId::local(Ulid::new(), RealmId::from_bytes([1u8; 32])),
497+
created_by: UserId::local(Ulid::r#gen(), RealmId::from_bytes([1u8; 32])),
498498
staging: false,
499499
partial: false,
500500
blob_size: 10,
@@ -608,7 +608,7 @@ mod tests {
608608
let driver_ctx = driver_context(storage_handle.clone());
609609

610610
let location = location();
611-
let version_id = Ulid::new();
611+
let version_id = Ulid::r#gen();
612612
seed_current_version(&storage_handle, &location, version_id).await;
613613
seed_multipart_metadata(
614614
&storage_handle,
@@ -653,7 +653,7 @@ mod tests {
653653
let driver_ctx = driver_context(storage_handle.clone());
654654

655655
let location = location();
656-
let version_id = Ulid::new();
656+
let version_id = Ulid::r#gen();
657657
seed_current_version(&storage_handle, &location, version_id).await;
658658

659659
let result = drive(
@@ -684,7 +684,7 @@ mod tests {
684684
let driver_ctx = driver_context(storage_handle.clone());
685685

686686
let location = location();
687-
let version_id = Ulid::new();
687+
let version_id = Ulid::r#gen();
688688
write(
689689
&storage_handle,
690690
BLOB_VERSIONS_KEYSPACE,
@@ -735,7 +735,7 @@ mod tests {
735735
storage::FjallStorage::open(temp_handle.path().to_str().unwrap()).unwrap();
736736
let driver_ctx = driver_context(storage_handle.clone());
737737

738-
let version_id = Ulid::new();
738+
let version_id = Ulid::r#gen();
739739
write(
740740
&storage_handle,
741741
BLOB_VERSIONS_KEYSPACE,

0 commit comments

Comments
 (0)