From 87e0d6d416fb03f033dd42494e9b7d40cdb66c48 Mon Sep 17 00:00:00 2001 From: J Robert Ray Date: Tue, 20 Feb 2024 16:37:40 -0800 Subject: [PATCH] Add more cases to legacy publish test Make a distinction between how the version appears in the recipe versus how it is written on the `spk publish` command line. What ends up in the remote repository is expected to match what is written in the recipe rather than what is given on the command line when publishing. Signed-off-by: J Robert Ray --- crates/spk-cli/group2/src/cmd_publish_test.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/spk-cli/group2/src/cmd_publish_test.rs b/crates/spk-cli/group2/src/cmd_publish_test.rs index f92730f9ea..da5d05c220 100644 --- a/crates/spk-cli/group2/src/cmd_publish_test.rs +++ b/crates/spk-cli/group2/src/cmd_publish_test.rs @@ -30,6 +30,7 @@ struct Opt { #[rstest] #[tokio::test] async fn test_publish_writes_with_legacy_version_tags( + #[values("1", "1.0", "1.0.0", "1.0.0.0", "1.0.0.0.0")] version_to_create: &str, #[values("1", "1.0", "1.0.0", "1.0.0.0", "1.0.0.0.0")] version_to_publish: &str, ) { let mut rt = spfs_runtime_with_tag_strategy::().await; @@ -43,9 +44,9 @@ async fn test_publish_writes_with_legacy_version_tags( ) .unwrap(); - let recipe = recipe!({"pkg": format!("my-local-pkg/{version_to_publish}")}); + let recipe = recipe!({"pkg": format!("my-local-pkg/{version_to_create}")}); rt.tmprepo.publish_recipe(&recipe).await.unwrap(); - let spec = spec!({"pkg": format!("my-local-pkg/{version_to_publish}/BGSHW3CN")}); + let spec = spec!({"pkg": format!("my-local-pkg/{version_to_create}/BGSHW3CN")}); rt.tmprepo .publish_package( &spec, @@ -115,12 +116,12 @@ async fn test_publish_writes_with_legacy_version_tags( for (tag_path, entry_type_filter) in [ ( "spk/spec/my-local-pkg", - Box::new(|tag: &_| matches!(tag, Ok(EntryType::Tag(tag)) if tag == version_to_publish)) + Box::new(|tag: &_| matches!(tag, Ok(EntryType::Tag(tag)) if tag == version_to_create)) as Box Fn(&'a Result) -> bool>, ), ( "spk/pkg/my-local-pkg", - Box::new(|tag| matches!(tag, Ok(EntryType::Folder(tag)) if tag == version_to_publish)), + Box::new(|tag| matches!(tag, Ok(EntryType::Folder(tag)) if tag == version_to_create)), ), ] .iter() @@ -133,7 +134,7 @@ async fn test_publish_writes_with_legacy_version_tags( .next() .await .is_some(), - "expected \"{tag_path}/{version_to_publish}\" tag to be found" + "expected \"{tag_path}/{version_to_create}\" tag to be found" ); } _ => panic!("expected SPFSWithVerbatimTags"), @@ -146,13 +147,13 @@ async fn test_publish_writes_with_legacy_version_tags( spfs.ls_tags(&RelativePathBuf::from("spk/spec/my-local-pkg")) .filter(|tag| { future::ready( - matches!(tag, Ok(EntryType::Tag(tag)) if tag == version_to_publish), + matches!(tag, Ok(EntryType::Tag(tag)) if tag == version_to_create), ) }) .next() .await .is_some(), - "expected \"{version_to_publish}\" tag to be found" + "expected \"{version_to_create}\" tag to be found" ); } _ => panic!("expected SPFSWithVerbatimTags"),