From 8679cc8a5498fbebc6b39fe16640edad571da286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kh=E1=BA=A3i?= Date: Sat, 2 May 2026 02:57:05 +0700 Subject: [PATCH] refactor: no star imports (#364) https://claude.ai/code/session_011yRgFgrJbtbneNyrvTJp32 --------- Co-authored-by: Claude --- pacquet/AGENTS.md | 6 +++ pacquet/CODE_STYLE_GUIDE.md | 37 +++++++++++++++++++ pacquet/crates/cli/src/cli_args/add.rs | 2 +- pacquet/crates/cli/src/cli_args/install.rs | 2 +- pacquet/crates/cli/src/state.rs | 2 +- pacquet/crates/fs/src/ensure_file.rs | 9 ++++- pacquet/crates/lockfile/src/comver.rs | 2 +- .../crates/lockfile/src/lockfile_version.rs | 2 +- pacquet/crates/lockfile/src/pkg_name.rs | 3 +- pacquet/crates/lockfile/src/pkg_name_ver.rs | 3 +- .../crates/lockfile/src/pkg_name_ver_peer.rs | 2 +- pacquet/crates/lockfile/src/pkg_ver_peer.rs | 3 +- .../crates/lockfile/src/project_snapshot.rs | 3 +- pacquet/crates/lockfile/src/resolution.rs | 6 ++- pacquet/crates/lockfile/src/save_lockfile.rs | 3 +- .../crates/lockfile/src/snapshot_dep_ref.rs | 3 +- .../crates/npmrc/src/custom_deserializer.rs | 8 +++- pacquet/crates/npmrc/src/lib.rs | 6 ++- pacquet/crates/npmrc/src/npmrc_auth.rs | 3 +- pacquet/crates/npmrc/src/workspace_yaml.rs | 5 ++- .../package-manager/src/build_snapshot.rs | 4 +- pacquet/crates/package-manager/src/install.rs | 2 +- .../src/install_package_from_registry.rs | 8 ++-- .../crates/package-manager/src/link_file.rs | 11 +++++- pacquet/crates/package-manifest/src/lib.rs | 3 +- pacquet/crates/registry/src/package.rs | 2 +- pacquet/crates/store-dir/src/cas_file.rs | 4 +- .../src/check_pkg_files_integrity.rs | 11 +++++- .../crates/store-dir/src/msgpackr_records.rs | 7 +++- pacquet/crates/store-dir/src/store_dir.rs | 2 +- pacquet/crates/store-dir/src/store_index.rs | 4 +- pacquet/crates/tarball/src/tests.rs | 16 ++++++-- 32 files changed, 146 insertions(+), 38 deletions(-) diff --git a/pacquet/AGENTS.md b/pacquet/AGENTS.md index 7e071f6f98..89435593bb 100644 --- a/pacquet/AGENTS.md +++ b/pacquet/AGENTS.md @@ -149,6 +149,12 @@ or treating the red as acceptable. scalar `assert_eq!`. - Follow [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/naming.html) for naming. +- **No star imports inside module bodies.** Write `use super::{Foo, bar}` + instead of `use super::*;`, and the same for any other glob whose + target is a module you control. Two forms stay allowed: external-crate + preludes such as `use rayon::prelude::*;` and root-of-module + re-exports such as `pub use submodule::*;` in a `lib.rs`. See the + "No star imports" section in `CODE_STYLE_GUIDE.md`. ### Preserve existing method chains diff --git a/pacquet/CODE_STYLE_GUIDE.md b/pacquet/CODE_STYLE_GUIDE.md index f19e04e3ef..0f2452b5f8 100644 --- a/pacquet/CODE_STYLE_GUIDE.md +++ b/pacquet/CODE_STYLE_GUIDE.md @@ -75,6 +75,43 @@ use std::{path::PathBuf, sync::Arc}; use std::os::unix::fs::PermissionsExt; ``` +### No star imports + +Avoid star (glob) imports inside the bodies of regular modules. Import items explicitly by name everywhere except the two cases noted below. The rule applies to production code, tests, integration tests, build scripts, and developer tooling under `tasks/`. + +The two exceptions are: + +1. **External-crate preludes**, such as `use rayon::prelude::*;` or `use assert_cmd::prelude::*;`. The upstream crate has already curated which items are intended to be glob-imported, so listing them out by hand creates a maintenance burden the moment the upstream prelude changes. Use the prelude in the form the crate documents. +2. **Re-exports at the root of a module or crate**, such as `pub use submodule::*;` in `lib.rs`. These are part of the public surface that the crate intentionally exposes, and listing the items individually duplicates information that already lives in the submodule. + +Star imports inside a module body are the case worth banning. They make it hard to tell where a name comes from, they hide accidental shadowing, and `use super::*;` is especially harmful in tests. The form pulls every privately imported item from the outer module into scope, so an import the production code no longer uses can keep compiling indefinitely as long as some test still references it. Removing dead imports becomes guesswork. + +```rust +// Bad +#[cfg(test)] +mod tests { + use super::*; +} + +// Good +#[cfg(test)] +mod tests { + use super::{ParsedThing, parse_thing}; +} +``` + +```rust +// Allowed (external-crate prelude) +use rayon::prelude::*; +use assert_cmd::prelude::*; +``` + +```rust +// Allowed (root-of-module re-export) +pub use comver::*; +pub use load_lockfile::*; +``` + ### Generic Parameter Naming Use **descriptive names** for type parameters, not single letters: diff --git a/pacquet/crates/cli/src/cli_args/add.rs b/pacquet/crates/cli/src/cli_args/add.rs index 5acf8e6e02..eeabb25a95 100644 --- a/pacquet/crates/cli/src/cli_args/add.rs +++ b/pacquet/crates/cli/src/cli_args/add.rs @@ -108,7 +108,7 @@ impl AddArgs { #[cfg(test)] mod tests { - use super::*; + use super::AddDependencyOptions; use pacquet_package_manifest::DependencyGroup; use pretty_assertions::assert_eq; diff --git a/pacquet/crates/cli/src/cli_args/install.rs b/pacquet/crates/cli/src/cli_args/install.rs index a394e2f4d4..545a071e92 100644 --- a/pacquet/crates/cli/src/cli_args/install.rs +++ b/pacquet/crates/cli/src/cli_args/install.rs @@ -75,7 +75,7 @@ impl InstallArgs { #[cfg(test)] mod tests { - use super::*; + use super::InstallDependencyOptions; use pacquet_package_manifest::DependencyGroup; use pretty_assertions::assert_eq; diff --git a/pacquet/crates/cli/src/state.rs b/pacquet/crates/cli/src/state.rs index 23852b452a..3a2a5f8ec2 100644 --- a/pacquet/crates/cli/src/state.rs +++ b/pacquet/crates/cli/src/state.rs @@ -82,7 +82,7 @@ where #[cfg(test)] mod tests { - use super::*; + use super::call_load_lockfile; use pretty_assertions::assert_eq; #[test] diff --git a/pacquet/crates/fs/src/ensure_file.rs b/pacquet/crates/fs/src/ensure_file.rs index 526e585607..0ac545afc5 100644 --- a/pacquet/crates/fs/src/ensure_file.rs +++ b/pacquet/crates/fs/src/ensure_file.rs @@ -507,9 +507,16 @@ fn strip_dash_suffix(name: &str) -> String { #[cfg(test)] mod tests { - use super::*; + use super::{ + EnsureFileError, ensure_file, file_equals_bytes, is_transient_rename_error, + rename_with_retry, temp_path_for, + }; + use std::{fs, io, path::Path}; use tempfile::tempdir; + #[cfg(unix)] + use super::{EMFILE, ENFILE, retry_on_fd_pressure}; + /// New-file path: contents land on disk. Mode handling is covered /// separately in `unix_mode_is_applied_on_new_files`. #[test] diff --git a/pacquet/crates/lockfile/src/comver.rs b/pacquet/crates/lockfile/src/comver.rs index b6b740006c..240d443894 100644 --- a/pacquet/crates/lockfile/src/comver.rs +++ b/pacquet/crates/lockfile/src/comver.rs @@ -56,7 +56,7 @@ impl From for String { #[cfg(test)] mod tests { - use super::*; + use super::ComVer; use pretty_assertions::assert_eq; #[test] diff --git a/pacquet/crates/lockfile/src/lockfile_version.rs b/pacquet/crates/lockfile/src/lockfile_version.rs index 0cdb03d58e..a30479403e 100644 --- a/pacquet/crates/lockfile/src/lockfile_version.rs +++ b/pacquet/crates/lockfile/src/lockfile_version.rs @@ -34,7 +34,7 @@ impl TryFrom for LockfileVersion { #[cfg(test)] mod tests { - use super::*; + use super::{ComVer, LockfileVersion, LockfileVersionError}; use pipe_trait::Pipe; use pretty_assertions::assert_eq; diff --git a/pacquet/crates/lockfile/src/pkg_name.rs b/pacquet/crates/lockfile/src/pkg_name.rs index f1cba56739..80e605fef2 100644 --- a/pacquet/crates/lockfile/src/pkg_name.rs +++ b/pacquet/crates/lockfile/src/pkg_name.rs @@ -89,7 +89,8 @@ impl From for String { #[cfg(test)] mod tests { - use super::*; + use super::{ParsePkgNameError, PkgName}; + use pipe_trait::Pipe; use pretty_assertions::assert_eq; #[test] diff --git a/pacquet/crates/lockfile/src/pkg_name_ver.rs b/pacquet/crates/lockfile/src/pkg_name_ver.rs index fc9006826e..ebf0cf4b96 100644 --- a/pacquet/crates/lockfile/src/pkg_name_ver.rs +++ b/pacquet/crates/lockfile/src/pkg_name_ver.rs @@ -11,7 +11,8 @@ pub type ParsePkgNameVerError = ParsePkgNameSuffixError; #[cfg(test)] mod tests { - use super::*; + use super::{ParsePkgNameVerError, PkgNameVer}; + use node_semver::Version; use pipe_trait::Pipe; use pretty_assertions::assert_eq; diff --git a/pacquet/crates/lockfile/src/pkg_name_ver_peer.rs b/pacquet/crates/lockfile/src/pkg_name_ver_peer.rs index 7188129402..e0d7a231a1 100644 --- a/pacquet/crates/lockfile/src/pkg_name_ver_peer.rs +++ b/pacquet/crates/lockfile/src/pkg_name_ver_peer.rs @@ -36,7 +36,7 @@ impl PkgNameVerPeer { #[cfg(test)] mod tests { - use super::*; + use super::PkgNameVerPeer; use pretty_assertions::assert_eq; fn name_peer_ver(name: &str, peer_ver: &str) -> PkgNameVerPeer { diff --git a/pacquet/crates/lockfile/src/pkg_ver_peer.rs b/pacquet/crates/lockfile/src/pkg_ver_peer.rs index 6711dbca86..1b11870c8a 100644 --- a/pacquet/crates/lockfile/src/pkg_ver_peer.rs +++ b/pacquet/crates/lockfile/src/pkg_ver_peer.rs @@ -81,7 +81,8 @@ impl From for String { #[cfg(test)] mod tests { - use super::*; + use super::{ParsePkgVerPeerError, PkgVerPeer}; + use node_semver::Version; use pretty_assertions::assert_eq; fn assert_ver_peer(received: PkgVerPeer, expected_version: Ver, expected_peer: Peer) diff --git a/pacquet/crates/lockfile/src/project_snapshot.rs b/pacquet/crates/lockfile/src/project_snapshot.rs index 3911ac4cb9..dacbd644f1 100644 --- a/pacquet/crates/lockfile/src/project_snapshot.rs +++ b/pacquet/crates/lockfile/src/project_snapshot.rs @@ -43,7 +43,8 @@ impl ProjectSnapshot { #[cfg(test)] mod tests { - use super::*; + use super::{ProjectSnapshot, ResolvedDependencySpec}; + use pacquet_package_manifest::DependencyGroup; use pretty_assertions::assert_eq; use text_block_macros::text_block; diff --git a/pacquet/crates/lockfile/src/resolution.rs b/pacquet/crates/lockfile/src/resolution.rs index 20574b2c3a..f2dc77f373 100644 --- a/pacquet/crates/lockfile/src/resolution.rs +++ b/pacquet/crates/lockfile/src/resolution.rs @@ -98,9 +98,13 @@ impl From for ResolutionSerde { #[cfg(test)] mod tests { - use super::*; + use super::{ + DirectoryResolution, GitResolution, LockfileResolution, RegistryResolution, + TarballResolution, + }; use crate::serialize_yaml; use pretty_assertions::assert_eq; + use ssri::Integrity; use text_block_macros::text_block; fn integrity(integrity_str: &str) -> Integrity { diff --git a/pacquet/crates/lockfile/src/save_lockfile.rs b/pacquet/crates/lockfile/src/save_lockfile.rs index 5b3d8d4d86..0fabd493f5 100644 --- a/pacquet/crates/lockfile/src/save_lockfile.rs +++ b/pacquet/crates/lockfile/src/save_lockfile.rs @@ -37,7 +37,8 @@ impl Lockfile { #[cfg(test)] mod tests { - use super::*; + use super::SaveLockfileError; + use crate::Lockfile; use pretty_assertions::assert_eq; use tempfile::tempdir; use text_block_macros::text_block; diff --git a/pacquet/crates/lockfile/src/snapshot_dep_ref.rs b/pacquet/crates/lockfile/src/snapshot_dep_ref.rs index 4eb945cd64..25fa2f48c1 100644 --- a/pacquet/crates/lockfile/src/snapshot_dep_ref.rs +++ b/pacquet/crates/lockfile/src/snapshot_dep_ref.rs @@ -130,7 +130,8 @@ impl From for SnapshotDepRef { #[cfg(test)] mod tests { - use super::*; + use super::{SnapshotDepRef, looks_like_alias}; + use crate::{PkgName, PkgNameVerPeer, PkgVerPeer}; use pretty_assertions::assert_eq; fn pkg_name(s: &str) -> PkgName { diff --git a/pacquet/crates/npmrc/src/custom_deserializer.rs b/pacquet/crates/npmrc/src/custom_deserializer.rs index d31c549c78..8ec28e1040 100644 --- a/pacquet/crates/npmrc/src/custom_deserializer.rs +++ b/pacquet/crates/npmrc/src/custom_deserializer.rs @@ -173,11 +173,17 @@ where #[cfg(test)] mod tests { - use super::*; + use super::default_store_dir; use crate::test_env_guard::EnvGuard; + use pacquet_store_dir::StoreDir; use pretty_assertions::assert_eq; use std::env; + #[cfg(windows)] + use super::{default_store_dir_windows, get_drive_letter}; + #[cfg(windows)] + use std::path::Path; + fn display_store_dir(store_dir: &StoreDir) -> String { store_dir.display().to_string().replace('\\', "/") } diff --git a/pacquet/crates/npmrc/src/lib.rs b/pacquet/crates/npmrc/src/lib.rs index f2e987cf10..5ee2e5cb6b 100644 --- a/pacquet/crates/npmrc/src/lib.rs +++ b/pacquet/crates/npmrc/src/lib.rs @@ -316,8 +316,10 @@ mod tests { use pretty_assertions::assert_eq; use tempfile::tempdir; - use super::*; - use crate::test_env_guard::EnvGuard; + use super::{NodeLinker, Npmrc, PackageImportMethod, fs}; + use crate::{custom_deserializer::default_store_dir, test_env_guard::EnvGuard}; + use pacquet_store_dir::StoreDir; + use pipe_trait::Pipe; fn display_store_dir(store_dir: &StoreDir) -> String { store_dir.display().to_string().replace('\\', "/") diff --git a/pacquet/crates/npmrc/src/npmrc_auth.rs b/pacquet/crates/npmrc/src/npmrc_auth.rs index 77aae9f255..a8f059d1df 100644 --- a/pacquet/crates/npmrc/src/npmrc_auth.rs +++ b/pacquet/crates/npmrc/src/npmrc_auth.rs @@ -64,7 +64,8 @@ impl NpmrcAuth { #[cfg(test)] mod tests { - use super::*; + use super::NpmrcAuth; + use crate::Npmrc; use pretty_assertions::assert_eq; #[test] diff --git a/pacquet/crates/npmrc/src/workspace_yaml.rs b/pacquet/crates/npmrc/src/workspace_yaml.rs index bf73a1f611..cc06cd6c7d 100644 --- a/pacquet/crates/npmrc/src/workspace_yaml.rs +++ b/pacquet/crates/npmrc/src/workspace_yaml.rs @@ -194,8 +194,11 @@ pub fn workspace_root_or(start: &Path) -> PathBuf { #[cfg(test)] mod tests { - use super::*; + use super::WorkspaceSettings; + use crate::{NodeLinker, Npmrc}; + use pacquet_store_dir::StoreDir; use pretty_assertions::assert_eq; + use std::{fs, path::Path}; #[test] fn parses_common_settings_from_yaml() { diff --git a/pacquet/crates/package-manager/src/build_snapshot.rs b/pacquet/crates/package-manager/src/build_snapshot.rs index dd8244d802..4278da84d8 100644 --- a/pacquet/crates/package-manager/src/build_snapshot.rs +++ b/pacquet/crates/package-manager/src/build_snapshot.rs @@ -115,11 +115,13 @@ pub fn build_package_snapshot( #[cfg(test)] mod tests { - use super::*; + use super::{BuildSnapshotError, build_package_snapshot, registry_package_key}; use node_semver::Version; + use pacquet_lockfile::{LockfileResolution, PkgName, PkgVerPeer}; use pacquet_registry::{PackageDistribution, PackageVersion}; use pretty_assertions::assert_eq; use ssri::Integrity; + use std::collections::HashMap; fn integrity(s: &str) -> Integrity { s.parse().expect("parse integrity string") diff --git a/pacquet/crates/package-manager/src/install.rs b/pacquet/crates/package-manager/src/install.rs index d09c051adf..3a960e3b2d 100644 --- a/pacquet/crates/package-manager/src/install.rs +++ b/pacquet/crates/package-manager/src/install.rs @@ -157,7 +157,7 @@ where #[cfg(test)] mod tests { - use super::*; + use super::{Install, InstallError}; use pacquet_npmrc::Npmrc; use pacquet_package_manifest::{DependencyGroup, PackageManifest}; use pacquet_registry_mock::AutoMockInstance; diff --git a/pacquet/crates/package-manager/src/install_package_from_registry.rs b/pacquet/crates/package-manager/src/install_package_from_registry.rs index a30f841a72..e9bae5bab1 100644 --- a/pacquet/crates/package-manager/src/install_package_from_registry.rs +++ b/pacquet/crates/package-manager/src/install_package_from_registry.rs @@ -159,14 +159,14 @@ impl<'a> InstallPackageFromRegistry<'a> { #[cfg(test)] mod tests { - use super::*; + use super::InstallPackageFromRegistry; use node_semver::Version; + use pacquet_network::ThrottledClient; use pacquet_npmrc::Npmrc; - use pacquet_store_dir::StoreDir; + use pacquet_store_dir::{SharedVerifiedFilesCache, StoreDir}; use pipe_trait::Pipe; use pretty_assertions::assert_eq; - use std::fs; - use std::path::Path; + use std::{fs, path::Path}; use tempfile::tempdir; fn create_config(store_dir: &Path, modules_dir: &Path, virtual_store_dir: &Path) -> Npmrc { diff --git a/pacquet/crates/package-manager/src/link_file.rs b/pacquet/crates/package-manager/src/link_file.rs index a0fb0fe3fd..a54eae6158 100644 --- a/pacquet/crates/package-manager/src/link_file.rs +++ b/pacquet/crates/package-manager/src/link_file.rs @@ -310,8 +310,17 @@ fn clone_or_copy_link(state: &AtomicU8, source: &Path, target: &Path) -> io::Res #[cfg(test)] mod tests { - use super::*; + use super::{ + LINK_STATE_CLONE, LINK_STATE_COPY, LINK_STATE_HARDLINK, LinkFileError, auto_link, + clone_or_copy_link, is_call_error, is_cross_device, link_file, + }; + use pacquet_npmrc::PackageImportMethod; use pretty_assertions::assert_eq; + use std::{ + fs, io, + path::{Path, PathBuf}, + sync::atomic::{AtomicU8, Ordering}, + }; use tempfile::tempdir; fn write_source(dir: &Path, name: &str, contents: &[u8]) -> PathBuf { diff --git a/pacquet/crates/package-manifest/src/lib.rs b/pacquet/crates/package-manifest/src/lib.rs index 05eac76323..060d844938 100644 --- a/pacquet/crates/package-manifest/src/lib.rs +++ b/pacquet/crates/package-manifest/src/lib.rs @@ -245,8 +245,9 @@ mod tests { use pretty_assertions::assert_eq; use tempfile::{NamedTempFile, tempdir}; - use super::*; + use super::{BundleDependencies, PackageManifest}; use crate::DependencyGroup; + use std::io::Write; #[test] fn test_init_package_json_content() { diff --git a/pacquet/crates/registry/src/package.rs b/pacquet/crates/registry/src/package.rs index b69195a847..78c2e7dc75 100644 --- a/pacquet/crates/registry/src/package.rs +++ b/pacquet/crates/registry/src/package.rs @@ -80,7 +80,7 @@ mod tests { use node_semver::Version; use pretty_assertions::assert_eq; - use super::*; + use super::PackageVersion; use crate::package_distribution::PackageDistribution; #[test] diff --git a/pacquet/crates/store-dir/src/cas_file.rs b/pacquet/crates/store-dir/src/cas_file.rs index 0c49b07474..b6173631fd 100644 --- a/pacquet/crates/store-dir/src/cas_file.rs +++ b/pacquet/crates/store-dir/src/cas_file.rs @@ -85,7 +85,9 @@ impl StoreDir { #[cfg(test)] mod tests { - use super::*; + use crate::StoreDir; + use sha2::{Digest, Sha512}; + use std::path::PathBuf; #[test] fn cas_file_path() { diff --git a/pacquet/crates/store-dir/src/check_pkg_files_integrity.rs b/pacquet/crates/store-dir/src/check_pkg_files_integrity.rs index 924693d6f5..8e4d1a2d7d 100644 --- a/pacquet/crates/store-dir/src/check_pkg_files_integrity.rs +++ b/pacquet/crates/store-dir/src/check_pkg_files_integrity.rs @@ -334,9 +334,16 @@ fn verify_file_integrity(path: &Path, digest: &str, algo: &str) -> bool { #[cfg(test)] mod tests { - use super::*; + use super::{VerifiedFilesCache, build_file_maps_from_index, check_pkg_files_integrity}; + use crate::{CafsFileInfo, PackageFilesIndex, StoreDir}; use pretty_assertions::assert_eq; - use std::{fs, io::Write, time::SystemTime}; + use sha2::{Digest, Sha512}; + use std::{ + fs, + io::Write, + path::PathBuf, + time::{SystemTime, UNIX_EPOCH}, + }; use tempfile::tempdir; /// Write `content` to the correct CAFS path under `store_dir` for diff --git a/pacquet/crates/store-dir/src/msgpackr_records.rs b/pacquet/crates/store-dir/src/msgpackr_records.rs index 34b04afc85..f388e144c0 100644 --- a/pacquet/crates/store-dir/src/msgpackr_records.rs +++ b/pacquet/crates/store-dir/src/msgpackr_records.rs @@ -930,8 +930,11 @@ fn write_bool(w: &mut Vec, b: bool) { #[cfg(test)] mod tests { - use super::*; - use crate::{CafsFileInfo, PackageFilesIndex}; + use super::{ + DecodeError, EncodeError, EncodeState, FIRST_INNER_SLOT, PKG_FILES_INDEX_SLOT, + RECORD_DEF_EXT_TYPE, SLOT_HI, encode_package_files_index, transcode_to_plain_msgpack, + }; + use crate::{CafsFileInfo, PackageFilesIndex, SideEffectsDiff}; use pretty_assertions::assert_eq; use std::collections::HashMap; diff --git a/pacquet/crates/store-dir/src/store_dir.rs b/pacquet/crates/store-dir/src/store_dir.rs index a65f72a69d..8f1fdfac1e 100644 --- a/pacquet/crates/store-dir/src/store_dir.rs +++ b/pacquet/crates/store-dir/src/store_dir.rs @@ -198,7 +198,7 @@ impl StoreDir { #[cfg(test)] mod tests { - use super::*; + use super::StoreDir; use pipe_trait::Pipe; use pretty_assertions::assert_eq; use std::path::Path; diff --git a/pacquet/crates/store-dir/src/store_index.rs b/pacquet/crates/store-dir/src/store_index.rs index 48978c1b6e..7d57cb8ba1 100644 --- a/pacquet/crates/store-dir/src/store_index.rs +++ b/pacquet/crates/store-dir/src/store_index.rs @@ -611,8 +611,10 @@ pub struct SideEffectsDiff { #[cfg(test)] mod tests { - use super::*; + use super::{CafsFileInfo, GET_MANY_CHUNK, PackageFilesIndex, StoreIndex, store_index_key}; + use crate::StoreDir; use pretty_assertions::assert_eq; + use std::collections::HashMap; use tempfile::tempdir; fn sample_index() -> PackageFilesIndex { diff --git a/pacquet/crates/tarball/src/tests.rs b/pacquet/crates/tarball/src/tests.rs index 0505cba24f..66202f2b12 100644 --- a/pacquet/crates/tarball/src/tests.rs +++ b/pacquet/crates/tarball/src/tests.rs @@ -1,10 +1,20 @@ -use pacquet_store_dir::{SharedVerifiedFilesCache, StoreIndex}; +use super::{ + DownloadTarballToStore, HttpStatusError, MemCache, NetworkError, PrefetchedCasPaths, RetryOpts, + TarballError, VerifyChecksumError, allocate_tarball_buffer, extract_tarball_entries, + fetch_and_extract_with_retry, is_transient_error, prefetch_cas_paths, +}; +use pacquet_network::ThrottledClient; +use pacquet_store_dir::{ + CafsFileInfo, PackageFilesIndex, SharedVerifiedFilesCache, StoreDir, StoreIndex, + store_index_key, +}; use pipe_trait::Pipe; use pretty_assertions::assert_eq; +use ssri::Integrity; +use std::{collections::HashMap, io::Cursor, path::PathBuf, sync::Arc, time::Duration}; +use tar::Archive; use tempfile::{TempDir, tempdir}; -use super::*; - fn integrity(integrity_str: &str) -> Integrity { integrity_str.parse().expect("parse integrity string") }