diff --git a/crates/crates_io_tarball/src/lib.rs b/crates/crates_io_tarball/src/lib.rs index b32e5f2eda4..1e822564828 100644 --- a/crates/crates_io_tarball/src/lib.rs +++ b/crates/crates_io_tarball/src/lib.rs @@ -183,7 +183,6 @@ impl AbstractFilesystem for PathsFileSystem { mod tests { use super::process_tarball; use crate::TarballBuilder; - use cargo_manifest::{MaybeInherited, StringOrBool}; use insta::{assert_debug_snapshot, assert_snapshot}; const MANIFEST: &[u8] = b"[package]\nname = \"foo\"\nversion = \"0.0.1\"\n"; @@ -196,10 +195,7 @@ mod tests { .build(); let tarball_info = assert_ok!(process_tarball("foo-0.0.1", &*tarball, MAX_SIZE).await); - assert_none!(tarball_info.vcs_info); - assert_none!(tarball_info.manifest.lib); - assert_eq!(tarball_info.manifest.bin, vec![]); - assert_eq!(tarball_info.manifest.example, vec![]); + assert_debug_snapshot!(tarball_info); let err = assert_err!(process_tarball("bar-0.0.1", &*tarball, MAX_SIZE).await); assert_snapshot!(err, @"invalid path found: foo-0.0.1/Cargo.toml"); @@ -224,8 +220,8 @@ mod tests { .build(); let tarball_info = assert_ok!(process_tarball("foo-0.0.1", &*tarball, MAX_SIZE).await); - let vcs_info = assert_some!(tarball_info.vcs_info); - assert_eq!(vcs_info.path_in_vcs, ""); + assert_some!(&tarball_info.vcs_info); + assert_debug_snapshot!(tarball_info); } #[tokio::test] @@ -237,8 +233,8 @@ mod tests { .build(); let tarball_info = assert_ok!(process_tarball("foo-0.0.1", &*tarball, MAX_SIZE).await); - let vcs_info = assert_some!(tarball_info.vcs_info); - assert_eq!(vcs_info.path_in_vcs, "path/in/vcs"); + assert_some!(&tarball_info.vcs_info); + assert_debug_snapshot!(tarball_info); } #[tokio::test] @@ -256,10 +252,7 @@ mod tests { .build(); let tarball_info = assert_ok!(process_tarball("foo-0.0.1", &*tarball, MAX_SIZE).await); - let package = assert_some!(tarball_info.manifest.package); - assert_matches!(package.readme, Some(MaybeInherited::Local(StringOrBool::String(s))) if s == "README.md"); - assert_matches!(package.repository, Some(MaybeInherited::Local(s)) if s == "https://github.com/foo/bar"); - assert_matches!(package.rust_version, Some(MaybeInherited::Local(s)) if s == "1.59"); + assert_debug_snapshot!(tarball_info); } #[tokio::test] @@ -275,8 +268,7 @@ mod tests { .build(); let tarball_info = assert_ok!(process_tarball("foo-0.0.1", &*tarball, MAX_SIZE).await); - let package = assert_some!(tarball_info.manifest.package); - assert_matches!(package.rust_version, Some(MaybeInherited::Local(s)) if s == "1.23"); + assert_debug_snapshot!(tarball_info); } #[tokio::test] @@ -286,8 +278,7 @@ mod tests { .build(); let tarball_info = assert_ok!(process_tarball("foo-0.0.1", &*tarball, MAX_SIZE).await); - let package = assert_some!(tarball_info.manifest.package); - assert_none!(package.readme); + assert_debug_snapshot!(tarball_info); } #[tokio::test] @@ -303,8 +294,7 @@ mod tests { .build(); let tarball_info = assert_ok!(process_tarball("foo-0.0.1", &*tarball, MAX_SIZE).await); - let package = assert_some!(tarball_info.manifest.package); - assert_matches!(package.readme, Some(MaybeInherited::Local(StringOrBool::Bool(b))) if !b); + assert_debug_snapshot!(tarball_info); } #[tokio::test] @@ -320,8 +310,7 @@ mod tests { .build(); let tarball_info = assert_ok!(process_tarball("foo-0.0.1", &*tarball, MAX_SIZE).await); - let package = assert_some!(tarball_info.manifest.package); - assert_matches!(package.repository, Some(MaybeInherited::Local(s)) if s == "https://github.com/foo/bar"); + assert_debug_snapshot!(tarball_info); } #[tokio::test] @@ -372,10 +361,7 @@ mod tests { .build(); let tarball_info = assert_ok!(process_tarball("foo-0.0.1", &*tarball, MAX_SIZE).await); - let lib = assert_some!(tarball_info.manifest.lib); - assert_debug_snapshot!(lib); - assert_eq!(tarball_info.manifest.bin, vec![]); - assert_eq!(tarball_info.manifest.example, vec![]); + assert_debug_snapshot!(tarball_info); } #[tokio::test] @@ -389,10 +375,7 @@ mod tests { .build(); let tarball_info = assert_ok!(process_tarball("foo-0.0.1", &*tarball, MAX_SIZE).await); - let lib = assert_some!(tarball_info.manifest.lib); - assert_debug_snapshot!(lib); - assert_debug_snapshot!(tarball_info.manifest.bin); - assert_debug_snapshot!(tarball_info.manifest.example); + assert_debug_snapshot!(tarball_info); } #[tokio::test] @@ -403,8 +386,6 @@ mod tests { .build(); let tarball_info = assert_ok!(process_tarball("foo-0.0.1", &*tarball, MAX_SIZE).await); - assert_none!(tarball_info.manifest.lib); - assert_debug_snapshot!(tarball_info.manifest.bin); - assert_eq!(tarball_info.manifest.example, vec![]); + assert_debug_snapshot!(tarball_info); } } diff --git a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__app.snap b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__app.snap index a5cb1102b7a..50d2a1b6cc8 100644 --- a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__app.snap +++ b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__app.snap @@ -1,24 +1,79 @@ --- source: crates/crates_io_tarball/src/lib.rs -expression: tarball_info.manifest.bin +expression: tarball_info --- -[ - Product { - path: Some( - "src/main.rs", +TarballInfo { + manifest: Manifest { + package: Some( + Package { + name: "foo", + edition: None, + version: Some( + Local( + "0.0.1", + ), + ), + build: None, + workspace: None, + authors: None, + links: None, + description: None, + homepage: None, + documentation: None, + readme: None, + keywords: None, + categories: None, + license: None, + license_file: None, + repository: None, + metadata: None, + rust_version: None, + exclude: None, + include: None, + default_run: None, + autolib: None, + autobins: None, + autoexamples: None, + autotests: None, + autobenches: None, + publish: None, + resolver: None, + }, ), - name: Some( - "foo", - ), - test: true, - doctest: true, - bench: true, - doc: true, - plugin: false, - proc_macro: false, - harness: true, - edition: None, - required_features: [], - crate_type: None, + cargo_features: None, + workspace: None, + dependencies: None, + dev_dependencies: None, + build_dependencies: None, + target: None, + features: None, + bin: [ + Product { + path: Some( + "src/main.rs", + ), + name: Some( + "foo", + ), + test: true, + doctest: true, + bench: true, + doc: true, + plugin: false, + proc_macro: false, + harness: true, + edition: None, + required_features: [], + crate_type: None, + }, + ], + bench: [], + test: [], + example: [], + patch: None, + lib: None, + profile: None, + badges: None, }, -] + vcs_info: None, +} diff --git a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__lib.snap b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__lib.snap index b2709bfd8ca..7272d2dfa02 100644 --- a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__lib.snap +++ b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__lib.snap @@ -1,26 +1,83 @@ --- source: crates/crates_io_tarball/src/lib.rs -expression: lib +expression: tarball_info --- -Product { - path: Some( - "src/lib.rs", - ), - name: Some( - "foo", - ), - test: true, - doctest: true, - bench: true, - doc: true, - plugin: false, - proc_macro: false, - harness: true, - edition: None, - required_features: [], - crate_type: Some( - [ - "lib", - ], - ), +TarballInfo { + manifest: Manifest { + package: Some( + Package { + name: "foo", + edition: None, + version: Some( + Local( + "0.0.1", + ), + ), + build: None, + workspace: None, + authors: None, + links: None, + description: None, + homepage: None, + documentation: None, + readme: None, + keywords: None, + categories: None, + license: None, + license_file: None, + repository: None, + metadata: None, + rust_version: None, + exclude: None, + include: None, + default_run: None, + autolib: None, + autobins: None, + autoexamples: None, + autotests: None, + autobenches: None, + publish: None, + resolver: None, + }, + ), + cargo_features: None, + workspace: None, + dependencies: None, + dev_dependencies: None, + build_dependencies: None, + target: None, + features: None, + bin: [], + bench: [], + test: [], + example: [], + patch: None, + lib: Some( + Product { + path: Some( + "src/lib.rs", + ), + name: Some( + "foo", + ), + test: true, + doctest: true, + bench: true, + doc: true, + plugin: false, + proc_macro: false, + harness: true, + edition: None, + required_features: [], + crate_type: Some( + [ + "lib", + ], + ), + }, + ), + profile: None, + badges: None, + }, + vcs_info: None, } diff --git a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__lib_with_bins_and_example.snap b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__lib_with_bins_and_example.snap index b2709bfd8ca..db43f0beddf 100644 --- a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__lib_with_bins_and_example.snap +++ b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__lib_with_bins_and_example.snap @@ -1,26 +1,143 @@ --- source: crates/crates_io_tarball/src/lib.rs -expression: lib +expression: tarball_info --- -Product { - path: Some( - "src/lib.rs", - ), - name: Some( - "foo", - ), - test: true, - doctest: true, - bench: true, - doc: true, - plugin: false, - proc_macro: false, - harness: true, - edition: None, - required_features: [], - crate_type: Some( - [ - "lib", +TarballInfo { + manifest: Manifest { + package: Some( + Package { + name: "foo", + edition: None, + version: Some( + Local( + "0.0.1", + ), + ), + build: None, + workspace: None, + authors: None, + links: None, + description: None, + homepage: None, + documentation: None, + readme: None, + keywords: None, + categories: None, + license: None, + license_file: None, + repository: None, + metadata: None, + rust_version: None, + exclude: None, + include: None, + default_run: None, + autolib: None, + autobins: None, + autoexamples: None, + autotests: None, + autobenches: None, + publish: None, + resolver: None, + }, + ), + cargo_features: None, + workspace: None, + dependencies: None, + dev_dependencies: None, + build_dependencies: None, + target: None, + features: None, + bin: [ + Product { + path: Some( + "src/bin/bar.rs", + ), + name: Some( + "bar", + ), + test: true, + doctest: true, + bench: true, + doc: true, + plugin: false, + proc_macro: false, + harness: true, + edition: None, + required_features: [], + crate_type: None, + }, + Product { + path: Some( + "src/bin/foo.rs", + ), + name: Some( + "foo", + ), + test: true, + doctest: true, + bench: true, + doc: true, + plugin: false, + proc_macro: false, + harness: true, + edition: None, + required_features: [], + crate_type: None, + }, ], - ), + bench: [], + test: [], + example: [ + Product { + path: Some( + "examples/how-to-use-foo.rs", + ), + name: Some( + "how-to-use-foo", + ), + test: true, + doctest: true, + bench: true, + doc: true, + plugin: false, + proc_macro: false, + harness: true, + edition: None, + required_features: [], + crate_type: Some( + [ + "bin", + ], + ), + }, + ], + patch: None, + lib: Some( + Product { + path: Some( + "src/lib.rs", + ), + name: Some( + "foo", + ), + test: true, + doctest: true, + bench: true, + doc: true, + plugin: false, + proc_macro: false, + harness: true, + edition: None, + required_features: [], + crate_type: Some( + [ + "lib", + ], + ), + }, + ), + profile: None, + badges: None, + }, + vcs_info: None, } diff --git a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test.snap b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test.snap new file mode 100644 index 00000000000..7d368fe0afc --- /dev/null +++ b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test.snap @@ -0,0 +1,60 @@ +--- +source: crates/crates_io_tarball/src/lib.rs +expression: tarball_info +--- +TarballInfo { + manifest: Manifest { + package: Some( + Package { + name: "foo", + edition: None, + version: Some( + Local( + "0.0.1", + ), + ), + build: None, + workspace: None, + authors: None, + links: None, + description: None, + homepage: None, + documentation: None, + readme: None, + keywords: None, + categories: None, + license: None, + license_file: None, + repository: None, + metadata: None, + rust_version: None, + exclude: None, + include: None, + default_run: None, + autolib: None, + autobins: None, + autoexamples: None, + autotests: None, + autobenches: None, + publish: None, + resolver: None, + }, + ), + cargo_features: None, + workspace: None, + dependencies: None, + dev_dependencies: None, + build_dependencies: None, + target: None, + features: None, + bin: [], + bench: [], + test: [], + example: [], + patch: None, + lib: None, + profile: None, + badges: None, + }, + vcs_info: None, +} diff --git a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_incomplete_vcs_info.snap b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_incomplete_vcs_info.snap new file mode 100644 index 00000000000..309d511eb9d --- /dev/null +++ b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_incomplete_vcs_info.snap @@ -0,0 +1,64 @@ +--- +source: crates/crates_io_tarball/src/lib.rs +expression: tarball_info +--- +TarballInfo { + manifest: Manifest { + package: Some( + Package { + name: "foo", + edition: None, + version: Some( + Local( + "0.0.1", + ), + ), + build: None, + workspace: None, + authors: None, + links: None, + description: None, + homepage: None, + documentation: None, + readme: None, + keywords: None, + categories: None, + license: None, + license_file: None, + repository: None, + metadata: None, + rust_version: None, + exclude: None, + include: None, + default_run: None, + autolib: None, + autobins: None, + autoexamples: None, + autotests: None, + autobenches: None, + publish: None, + resolver: None, + }, + ), + cargo_features: None, + workspace: None, + dependencies: None, + dev_dependencies: None, + build_dependencies: None, + target: None, + features: None, + bin: [], + bench: [], + test: [], + example: [], + patch: None, + lib: None, + profile: None, + badges: None, + }, + vcs_info: Some( + CargoVcsInfo { + path_in_vcs: "", + }, + ), +} diff --git a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_lowercase_manifest.snap b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_lowercase_manifest.snap new file mode 100644 index 00000000000..ecf1471317e --- /dev/null +++ b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_lowercase_manifest.snap @@ -0,0 +1,64 @@ +--- +source: crates/crates_io_tarball/src/lib.rs +expression: tarball_info +--- +TarballInfo { + manifest: Manifest { + package: Some( + Package { + name: "foo", + edition: None, + version: Some( + Local( + "0.0.1", + ), + ), + build: None, + workspace: None, + authors: None, + links: None, + description: None, + homepage: None, + documentation: None, + readme: None, + keywords: None, + categories: None, + license: None, + license_file: None, + repository: Some( + Local( + "https://github.com/foo/bar", + ), + ), + metadata: None, + rust_version: None, + exclude: None, + include: None, + default_run: None, + autolib: None, + autobins: None, + autoexamples: None, + autotests: None, + autobenches: None, + publish: None, + resolver: None, + }, + ), + cargo_features: None, + workspace: None, + dependencies: None, + dev_dependencies: None, + build_dependencies: None, + target: None, + features: None, + bin: [], + bench: [], + test: [], + example: [], + patch: None, + lib: None, + profile: None, + badges: None, + }, + vcs_info: None, +} diff --git a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_manifest.snap b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_manifest.snap new file mode 100644 index 00000000000..a163d2768df --- /dev/null +++ b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_manifest.snap @@ -0,0 +1,74 @@ +--- +source: crates/crates_io_tarball/src/lib.rs +expression: tarball_info +--- +TarballInfo { + manifest: Manifest { + package: Some( + Package { + name: "foo", + edition: None, + version: Some( + Local( + "0.0.1", + ), + ), + build: None, + workspace: None, + authors: None, + links: None, + description: None, + homepage: None, + documentation: None, + readme: Some( + Local( + String( + "README.md", + ), + ), + ), + keywords: None, + categories: None, + license: None, + license_file: None, + repository: Some( + Local( + "https://github.com/foo/bar", + ), + ), + metadata: None, + rust_version: Some( + Local( + "1.59", + ), + ), + exclude: None, + include: None, + default_run: None, + autolib: None, + autobins: None, + autoexamples: None, + autotests: None, + autobenches: None, + publish: None, + resolver: None, + }, + ), + cargo_features: None, + workspace: None, + dependencies: None, + dev_dependencies: None, + build_dependencies: None, + target: None, + features: None, + bin: [], + bench: [], + test: [], + example: [], + patch: None, + lib: None, + profile: None, + badges: None, + }, + vcs_info: None, +} diff --git a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_manifest_with_boolean_readme.snap b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_manifest_with_boolean_readme.snap new file mode 100644 index 00000000000..b86b2eed48f --- /dev/null +++ b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_manifest_with_boolean_readme.snap @@ -0,0 +1,66 @@ +--- +source: crates/crates_io_tarball/src/lib.rs +expression: tarball_info +--- +TarballInfo { + manifest: Manifest { + package: Some( + Package { + name: "foo", + edition: None, + version: Some( + Local( + "0.0.1", + ), + ), + build: None, + workspace: None, + authors: None, + links: None, + description: None, + homepage: None, + documentation: None, + readme: Some( + Local( + Bool( + false, + ), + ), + ), + keywords: None, + categories: None, + license: None, + license_file: None, + repository: None, + metadata: None, + rust_version: None, + exclude: None, + include: None, + default_run: None, + autolib: None, + autobins: None, + autoexamples: None, + autotests: None, + autobenches: None, + publish: None, + resolver: None, + }, + ), + cargo_features: None, + workspace: None, + dependencies: None, + dev_dependencies: None, + build_dependencies: None, + target: None, + features: None, + bin: [], + bench: [], + test: [], + example: [], + patch: None, + lib: None, + profile: None, + badges: None, + }, + vcs_info: None, +} diff --git a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_manifest_with_default_readme.snap b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_manifest_with_default_readme.snap new file mode 100644 index 00000000000..7d368fe0afc --- /dev/null +++ b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_manifest_with_default_readme.snap @@ -0,0 +1,60 @@ +--- +source: crates/crates_io_tarball/src/lib.rs +expression: tarball_info +--- +TarballInfo { + manifest: Manifest { + package: Some( + Package { + name: "foo", + edition: None, + version: Some( + Local( + "0.0.1", + ), + ), + build: None, + workspace: None, + authors: None, + links: None, + description: None, + homepage: None, + documentation: None, + readme: None, + keywords: None, + categories: None, + license: None, + license_file: None, + repository: None, + metadata: None, + rust_version: None, + exclude: None, + include: None, + default_run: None, + autolib: None, + autobins: None, + autoexamples: None, + autotests: None, + autobenches: None, + publish: None, + resolver: None, + }, + ), + cargo_features: None, + workspace: None, + dependencies: None, + dev_dependencies: None, + build_dependencies: None, + target: None, + features: None, + bin: [], + bench: [], + test: [], + example: [], + patch: None, + lib: None, + profile: None, + badges: None, + }, + vcs_info: None, +} diff --git a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_manifest_with_project.snap b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_manifest_with_project.snap new file mode 100644 index 00000000000..caec023b7eb --- /dev/null +++ b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_manifest_with_project.snap @@ -0,0 +1,64 @@ +--- +source: crates/crates_io_tarball/src/lib.rs +expression: tarball_info +--- +TarballInfo { + manifest: Manifest { + package: Some( + Package { + name: "foo", + edition: None, + version: Some( + Local( + "0.0.1", + ), + ), + build: None, + workspace: None, + authors: None, + links: None, + description: None, + homepage: None, + documentation: None, + readme: None, + keywords: None, + categories: None, + license: None, + license_file: None, + repository: None, + metadata: None, + rust_version: Some( + Local( + "1.23", + ), + ), + exclude: None, + include: None, + default_run: None, + autolib: None, + autobins: None, + autoexamples: None, + autotests: None, + autobenches: None, + publish: None, + resolver: None, + }, + ), + cargo_features: None, + workspace: None, + dependencies: None, + dev_dependencies: None, + build_dependencies: None, + target: None, + features: None, + bin: [], + bench: [], + test: [], + example: [], + patch: None, + lib: None, + profile: None, + badges: None, + }, + vcs_info: None, +} diff --git a/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_vcs_info.snap b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_vcs_info.snap new file mode 100644 index 00000000000..63ab7fb2053 --- /dev/null +++ b/crates/crates_io_tarball/src/snapshots/crates_io_tarball__tests__process_tarball_test_vcs_info.snap @@ -0,0 +1,64 @@ +--- +source: crates/crates_io_tarball/src/lib.rs +expression: tarball_info +--- +TarballInfo { + manifest: Manifest { + package: Some( + Package { + name: "foo", + edition: None, + version: Some( + Local( + "0.0.1", + ), + ), + build: None, + workspace: None, + authors: None, + links: None, + description: None, + homepage: None, + documentation: None, + readme: None, + keywords: None, + categories: None, + license: None, + license_file: None, + repository: None, + metadata: None, + rust_version: None, + exclude: None, + include: None, + default_run: None, + autolib: None, + autobins: None, + autoexamples: None, + autotests: None, + autobenches: None, + publish: None, + resolver: None, + }, + ), + cargo_features: None, + workspace: None, + dependencies: None, + dev_dependencies: None, + build_dependencies: None, + target: None, + features: None, + bin: [], + bench: [], + test: [], + example: [], + patch: None, + lib: None, + profile: None, + badges: None, + }, + vcs_info: Some( + CargoVcsInfo { + path_in_vcs: "path/in/vcs", + }, + ), +}