Skip to content

Commit

Permalink
Add more cases to legacy publish test
Browse files Browse the repository at this point in the history
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 <jrray@jrray.org>
  • Loading branch information
jrray committed Feb 26, 2024
1 parent 55b9eda commit 87e0d6d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions crates/spk-cli/group2/src/cmd_publish_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<NormalizedTagStrategy>().await;
Expand All @@ -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,
Expand Down Expand Up @@ -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<dyn for<'a> Fn(&'a Result<EntryType, spfs::Error>) -> 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()
Expand All @@ -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"),
Expand All @@ -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"),
Expand Down

0 comments on commit 87e0d6d

Please sign in to comment.