Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2793,7 +2793,7 @@ and regression tests were added throughout (the lib + integration suites grow by

### Tests

- New `tests/telemetry_e2e.rs` end-to-end behavioral coverage:
- New `tests/cli/telemetry_e2e.rs` end-to-end behavioral coverage:
apply/scan/get/list emit telemetry against a wiremock recorder;
`SOCKET_OFFLINE=1` produces zero telemetry POSTs across all four;
scan falls back on 401 + tags the resulting event; scan does NOT
Expand Down
8 changes: 4 additions & 4 deletions crates/socket-patch-cli/CLI_CONTRACT.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/socket-patch-cli/src/commands/scan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3243,7 +3243,7 @@ mod tests {

// ---- redirectState envelope block (read-only cross-mode visibility) ----
// The end-to-end envelope placement (report-only + agent runs carry it,
// hosted/vendored runs don't) is pinned by `tests/scan_invariants.rs`;
// hosted/vendored runs don't) is pinned by `tests/scan/scan_invariants.rs`;
// these pin the block builder's own gates and shape.

/// Pins present ⇒ the block exists with each pin's canonical purl +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,8 @@ fn unmatched_purl_exit_semantics_are_pinned() {
assert_eq!(v2["status"], "partialFailure", "{v2}");
}

#[path = "vlt_hosted_common/mod.rs"]
mod vlt_hosted_common;
#[path = "vlt_hosted_common/vendored.rs"]
mod vlt_vendored;
use crate::vlt_hosted_common;
use crate::vlt_vendored;

/// A vlt-vendored purl: `apply` yields it to the vendor ledger (the
/// committed dir artifact is what vlt installs), leaves `.socket/`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ use serde_json::{json, Value};
use wiremock::matchers::{method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};

#[path = "common/mod.rs"]
mod common;
use crate::common;

use common::{git_sha256, parse_json_envelope, run_with_env};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

use std::path::Path;

#[path = "common/mod.rs"]
mod common;
use crate::common;

use common::{
git_sha256, parse_json_envelope, run_with_env, write_blob, write_minimal_manifest, PatchEntry,
Expand Down
21 changes: 21 additions & 0 deletions crates/socket-patch-cli/tests/apply/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! `apply`: invariants, network behavior, silent/exit modes and the gem and npm multi-copy apply paths.
//!
//! One test binary per command: each module was its own binary.

#[path = "../common/mod.rs"]
mod common;
#[path = "../vlt_hosted_common/mod.rs"]
mod vlt_hosted_common;
#[path = "../vlt_hosted_common/vendored.rs"]
mod vlt_vendored;

mod apply_invariants;
mod apply_network;
mod cli_gem_variant_mismatch_policy;
mod covgap_commands_apply;
mod e2e_safety_advisories;
mod in_process_gem_config_warning;
mod in_process_gem_fallback_home;
mod in_process_gem_multicopy;
mod in_process_npm_multicopy;
mod in_process_variant_apply_failure;
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ use std::process::Command;
use base64::Engine as _;
use wiremock::MockServer;

#[path = "common/mod.rs"]
mod common;
#[path = "vlt_hosted_common/mod.rs"]
mod vlt_hosted_common;
#[path = "vlt_hosted_common/vendored.rs"]
mod vlt_vendored;
use crate::common;
use crate::vlt_hosted_common;
use crate::vlt_vendored;

// ---------------------------------------------------------------------------
// `--debug` provenance echoes (GlobalArgs::telemetry_credentials, config layer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#![cfg(unix)]

#[path = "common/pty_io.rs"]
mod pty_io;
use std::path::{Path, PathBuf};
use std::time::Duration;

Expand All @@ -26,8 +24,7 @@ use wiremock::{Mock, MockServer, ResponseTemplate};
// Pulled in for `git_sha256` (the patch-view blob fixture below must clear
// the "patch has no applicable files" guardrail with a real blob
// hash). Read-only reuse of the shared helper module.
#[path = "common/mod.rs"]
mod common;
use crate::common;

const ORG_SLUG: &str = "test-org";
const UUID_A: &str = "11111111-1111-4111-8111-111111111111";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

#![cfg(unix)]

#[path = "common/pty_io.rs"]
mod pty_io;
use std::path::{Path, PathBuf};
use std::time::Duration;

Expand Down
21 changes: 21 additions & 0 deletions crates/socket-patch-cli/tests/cli/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! Global CLI behavior: API client errors, dry-run paths, output modes, prompts, telemetry and `list`.
//!
//! One test binary per command: each module was its own binary.

#[path = "../common/mod.rs"]
mod common;
#[path = "../common/pty_io.rs"]
mod pty_io;
#[path = "../vlt_hosted_common/mod.rs"]
mod vlt_hosted_common;
#[path = "../vlt_hosted_common/vendored.rs"]
mod vlt_vendored;

mod api_client_errors_e2e;
mod cli_dry_run_paths_e2e;
mod covgap_api_client;
mod covgap_commands_list;
mod covgap_output;
mod interactive_prompts_e2e;
mod output_modes_e2e;
mod telemetry_e2e;
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use std::path::Path;

use sha2::{Digest, Sha256};

#[path = "common/mod.rs"]
mod common;
use crate::common;

fn git_sha256(content: &[u8]) -> String {
let header = format!("blob {}\0", content.len());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
use wiremock::matchers::{method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};

#[path = "common/mod.rs"]
mod common;
use crate::common;

const ORG: &str = "test-org";
const UUID: &str = "22222222-2222-4222-8222-222222222222";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
use wiremock::matchers::{method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};

#[path = "common/mod.rs"]
mod common;
use crate::common;

const ORG: &str = "test-org";
const GHSA: &str = "GHSA-dbld-json-once";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use wiremock::{Mock, MockServer, ResponseTemplate};
// inherits the developer's shell — `SOCKET_PROXY_URL` outranks the proxy
// these tests pin, and `SOCKET_MANIFEST_PATH` makes a *passing* test write its manifest and
// blobs into whatever real project the variable points at.
#[path = "common/mod.rs"]
mod common;
use crate::common;

const ORG_SLUG: &str = "test-org";
const UUID_A: &str = "11111111-1111-4111-8111-111111111111";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use std::path::Path;
use wiremock::matchers::{method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};

#[path = "common/mod.rs"]
mod common;
use crate::common;

const ORG_SLUG: &str = "test-org";
const UUID: &str = "11111111-1111-4111-8111-111111111111";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ use std::path::Path;
use wiremock::matchers::{method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};

#[path = "common/mod.rs"]
mod common;
#[path = "npm_e2e_common/manifestless.rs"]
mod npm_e2e_common;
#[path = "vex_e2e_common/mod.rs"]
mod vex_e2e_common;
use crate::common;
use crate::npm_e2e_common;
use crate::vex_e2e_common;

const ORG: &str = "test-org";
const NAME: &str = "getmodes-pkg";
Expand Down Expand Up @@ -235,7 +232,7 @@ async fn get_uuid_hosted_json_envelope_nests_redirect() {
// committed the run writes no `.npmrc` (so `rewrittenFiles` stays the
// lock alone) and emits exactly the already-set
// `redirect_npm_allow_remote` caveat (the auto-config has its own suite:
// tests/redirect_npm_allow_remote.rs).
// tests/vendor/redirect_npm_allow_remote.rs).
std::fs::write(tmp.path().join(".npmrc"), "allow-remote=all\n").unwrap();

let (code, stdout, stderr) = run_get(
Expand Down Expand Up @@ -594,7 +591,7 @@ async fn get_hosted_dry_run_json_envelope() {
// committed the run writes no `.npmrc` (so `rewrittenFiles` stays the
// lock alone) and emits exactly the already-set
// `redirect_npm_allow_remote` caveat (the auto-config has its own suite:
// tests/redirect_npm_allow_remote.rs).
// tests/vendor/redirect_npm_allow_remote.rs).
std::fs::write(tmp.path().join(".npmrc"), "allow-remote=all\n").unwrap();
let lock_before = std::fs::read_to_string(tmp.path().join("package-lock.json")).unwrap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
use wiremock::matchers::{method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};

#[path = "common/mod.rs"]
mod common;
use crate::common;

const ORG: &str = "test-org";
const UUID: &str = "11111111-1111-4111-8111-111111111111";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
use wiremock::matchers::{method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};

#[path = "common/mod.rs"]
mod common;
use crate::common;

const ORG: &str = "test-org";
const OLD_UUID: &str = "00000000-0000-4000-8000-000000000000";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
use std::path::{Path, PathBuf};
use std::process::Command;

#[path = "common/cache_env.rs"]
mod cache_env;
use crate::cache_env;

fn binary() -> PathBuf {
env!("CARGO_BIN_EXE_socket-patch").into()
Expand Down
21 changes: 21 additions & 0 deletions crates/socket-patch-cli/tests/get/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! `get`: batch paths, edge cases, invariants, modes, nested apply flags, update summaries and global packages.
//!
//! One test binary per command: each module was its own binary.

#[path = "../common/mod.rs"]
mod common;
#[path = "../npm_e2e_common/manifestless.rs"]
mod npm_e2e_common;
#[path = "../vex_e2e_common/mod.rs"]
mod vex_e2e_common;
use common::cache_env;

mod cli_get_silent_errors;
mod coverage_fix_get_double_json;
mod get_batch_paths_e2e;
mod get_edge_cases_e2e;
mod get_invariants;
mod get_modes_e2e;
mod get_nested_apply_api_flags_e2e;
mod get_update_summary_e2e;
mod global_packages_e2e;
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@
//! remove_invariants.rs / remove_duality_invariants.rs /
//! interactive_prompts_e2e.rs.

#[path = "common/pty_io.rs"]
mod pty_io;
use std::path::{Path, PathBuf};

#[path = "common/mod.rs"]
mod common;
#[path = "vlt_hosted_common/mod.rs"]
mod vlt_hosted_common;
#[path = "vlt_hosted_common/vendored.rs"]
mod vlt_vendored;
use crate::common;
use crate::vlt_hosted_common;
use crate::vlt_vendored;

/// Spawn `socket-patch remove` with the scrubbed env plus telemetry
/// disabled; `env` entries land last so per-test injections survive.
Expand Down
17 changes: 17 additions & 0 deletions crates/socket-patch-cli/tests/remove/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//! `remove`: invariants, duality with rollback, and network behavior.
//!
//! One test binary per command: each module was its own binary.

#[path = "../common/mod.rs"]
mod common;
#[path = "../common/pty_io.rs"]
mod pty_io;
#[path = "../vlt_hosted_common/mod.rs"]
mod vlt_hosted_common;
#[path = "../vlt_hosted_common/vendored.rs"]
mod vlt_vendored;

mod covgap_commands_remove;
mod remove_duality_invariants;
mod remove_invariants;
mod remove_network;
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

use std::path::{Path, PathBuf};

#[path = "common/mod.rs"]
mod common;
use crate::common;

/// Spawn `socket-patch remove` with the scrubbed env (`common::run_with_env`)
/// plus telemetry disabled; `env` entries land last so per-test injections
Expand Down Expand Up @@ -875,10 +874,8 @@ fn drift_kept_vendored_remove_is_partial_failure() {
);
}

#[path = "vlt_hosted_common/mod.rs"]
mod vlt_hosted_common;
#[path = "vlt_hosted_common/vendored.rs"]
mod vlt_vendored;
use crate::vlt_hosted_common;
use crate::vlt_vendored;

/// `remove --preserve-state` of a vlt-vendored purl restores the registry
/// lock and package.json but keeps the directory artifact and the ledger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

use std::path::{Path, PathBuf};

#[path = "common/mod.rs"]
mod common;
use crate::common;

const TWO_PATCH_MANIFEST: &str = r#"{
"patches": {
Expand Down Expand Up @@ -1039,10 +1038,8 @@ fn remove_dry_run_with_rollback_does_not_create_blobs_dir() {
assert!(litter.is_empty(), "no stage litter: {litter:?}");
}

#[path = "vlt_hosted_common/mod.rs"]
mod vlt_hosted_common;
#[path = "vlt_hosted_common/vendored.rs"]
mod vlt_vendored;
use crate::vlt_hosted_common;
use crate::vlt_vendored;

/// `remove --skip-rollback` of a vlt-vendored purl drops the manifest
/// record only: the vlt wiring, the directory artifact and the ledger entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,3 @@ async fn repair_inventory_refresh_persist_failure_stays_loud() {
);
}

#[path = "vlt_hosted_common/mod.rs"]
mod vlt_hosted_common;
#[path = "vlt_hosted_common/vendored.rs"]
mod vlt_vendored;
26 changes: 26 additions & 0 deletions crates/socket-patch-cli/tests/repair/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//! `repair`: invariants and vendored-tree repair across flavors.
//!
//! One test binary per command: each module was its own binary.

#[path = "../common/mod.rs"]
mod common;
// `bun.rs` embeds its own copy of `vex_e2e_common`, which
// `repair_vendor_e2e` also loads directly.
#[allow(clippy::duplicate_mod)]
#[path = "../vex_e2e_common/bun.rs"]
mod bun_vex;
#[path = "../npm_e2e_common/manifestless.rs"]
mod npm_e2e_common;
#[path = "../vex_e2e_common/mod.rs"]
mod vex_e2e_common;
#[path = "../vlt_hosted_common/mod.rs"]
mod vlt_hosted_common;
#[path = "../vlt_hosted_common/vendored.rs"]
mod vlt_vendored;

mod coverage_fix_repair_vendor_predelete;
mod covgap_commands_repair;
mod covgap_commands_repair_vendor;
mod repair_invariants;
mod repair_vendor_e2e;
mod repair_vendor_flavors_e2e;
Loading
Loading