Skip to content

Commit 156dc02

Browse files
committed
Thread DomainPaths through publish.rs push-test seed helper
1 parent 7996434 commit 156dc02

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

quilt-rs/src/flow/publish.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ mod tests {
289289
};
290290

291291
let storage = MockStorage::default();
292+
let paths = DomainPaths::new(PathBuf::from("/foo"));
292293
storage
293294
.write_byte_stream(PathBuf::from("/working-dir/foo"), ByteStream::default())
294295
.await?;
@@ -310,7 +311,7 @@ mod tests {
310311
let err = publish_package(
311312
lineage,
312313
&mut manifest,
313-
&DomainPaths::new(PathBuf::from("/")),
314+
&paths,
314315
&storage,
315316
&remote,
316317
PathBuf::from("/working-dir"),
@@ -337,17 +338,20 @@ mod tests {
337338
/// Seeds working-dir and remote object storage with an empty file at
338339
/// `{hash_hex}`, and returns a `(storage, remote)` pair ready for use
339340
/// by `publish_package` with a first-push lineage.
340-
async fn setup_storages_for_commit_and_push(hash_hex: &str) -> Res<(MockStorage, MockRemote)> {
341+
async fn setup_storages_for_commit_and_push(
342+
paths: &DomainPaths,
343+
hash_hex: &str,
344+
) -> Res<(MockStorage, MockRemote)> {
341345
let storage = MockStorage::default();
342346
storage
343347
.write_byte_stream(PathBuf::from("/working-dir/foo"), ByteStream::default())
344348
.await?;
345349

346350
let remote = MockRemote::default();
347-
// Commit rewrites the row's physical_key to file:///.quilt/objects/{hash}.
351+
// Commit rewrites the row's physical_key to file://<objects_dir>/{hash}.
348352
// Push reads that path through MockRemote's own storage
349353
// (see MockRemote::upload_file), so seed the same empty file there too.
350-
let object_path = PathBuf::from(format!("/.quilt/objects/{hash_hex}"));
354+
let object_path = paths.objects_dir().join(hash_hex);
351355
remote
352356
.storage
353357
.write_byte_stream(object_path, ByteStream::default())
@@ -413,8 +417,9 @@ mod tests {
413417
let manifest_src = fixtures::manifest_with_objects_all_sizes::manifest().await?;
414418
let added = row_from_fixture(&manifest_src, "0mb.bin");
415419

420+
let paths = DomainPaths::new(PathBuf::from("/foo"));
416421
let (storage, remote) =
417-
setup_storages_for_commit_and_push(fixtures::objects::ZERO_HASH_HEX).await?;
422+
setup_storages_for_commit_and_push(&paths, fixtures::objects::ZERO_HASH_HEX).await?;
418423

419424
let status = InstalledPackageStatus {
420425
changes: BTreeMap::from([(PathBuf::from("foo"), Change::Added(added))]),
@@ -426,7 +431,7 @@ mod tests {
426431
let outcome = publish_package(
427432
first_push_lineage_with_foo(),
428433
&mut manifest,
429-
&DomainPaths::new(PathBuf::from("/")),
434+
&paths,
430435
&storage,
431436
&remote,
432437
PathBuf::from("/working-dir"),
@@ -471,10 +476,10 @@ mod tests {
471476
)
472477
.await?;
473478
let remote = MockRemote::default();
474-
let object_path = PathBuf::from(format!(
475-
"/.quilt/objects/{}",
476-
fixtures::objects::LESS_THAN_8MB_HASH_HEX
477-
));
479+
let paths = DomainPaths::new(PathBuf::from("/foo"));
480+
let object_path = paths
481+
.objects_dir()
482+
.join(fixtures::objects::LESS_THAN_8MB_HASH_HEX);
478483
remote
479484
.storage
480485
.write_byte_stream(
@@ -498,7 +503,7 @@ mod tests {
498503
let outcome = publish_package(
499504
first_push_lineage_with_foo(),
500505
&mut manifest,
501-
&DomainPaths::new(PathBuf::from("/")),
506+
&paths,
502507
&storage,
503508
&remote,
504509
PathBuf::from("/working-dir"),
@@ -533,8 +538,9 @@ mod tests {
533538

534539
// Remove has nothing to copy into the object store, but setup still
535540
// seeds /working-dir/foo so the helper stays uniform across tests.
541+
let paths = DomainPaths::new(PathBuf::from("/foo"));
536542
let (storage, remote) =
537-
setup_storages_for_commit_and_push(fixtures::objects::ZERO_HASH_HEX).await?;
543+
setup_storages_for_commit_and_push(&paths, fixtures::objects::ZERO_HASH_HEX).await?;
538544

539545
let status = InstalledPackageStatus {
540546
changes: BTreeMap::from([(PathBuf::from("foo"), Change::Removed(existing.clone()))]),
@@ -547,7 +553,7 @@ mod tests {
547553
let outcome = publish_package(
548554
first_push_lineage_with_foo(),
549555
&mut manifest,
550-
&DomainPaths::new(PathBuf::from("/")),
556+
&paths,
551557
&storage,
552558
&remote,
553559
PathBuf::from("/working-dir"),
@@ -584,8 +590,9 @@ mod tests {
584590
let manifest_src = fixtures::manifest_with_objects_all_sizes::manifest().await?;
585591
let added = row_from_fixture(&manifest_src, "0mb.bin");
586592

593+
let paths = DomainPaths::new(PathBuf::from("/foo"));
587594
let (storage, remote) =
588-
setup_storages_for_commit_and_push(fixtures::objects::ZERO_HASH_HEX).await?;
595+
setup_storages_for_commit_and_push(&paths, fixtures::objects::ZERO_HASH_HEX).await?;
589596

590597
let status = InstalledPackageStatus {
591598
changes: BTreeMap::from([(PathBuf::from("foo"), Change::Added(added))]),
@@ -597,7 +604,7 @@ mod tests {
597604
let outcome = publish_package(
598605
first_push_lineage_with_foo(),
599606
&mut manifest,
600-
&DomainPaths::new(PathBuf::from("/")),
607+
&paths,
601608
&storage,
602609
&remote,
603610
PathBuf::from("/working-dir"),

0 commit comments

Comments
 (0)