mirror of
https://github.com/openai/codex.git
synced 2026-09-10 20:26:47 +00:00
Gate capture tests and fix argument comments
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
use super::AnalyticsEventsClient;
|
||||
use super::AnalyticsEventsDestination;
|
||||
use super::AnalyticsEventsQueue;
|
||||
#[cfg(debug_assertions)]
|
||||
use super::capture_track_events_request;
|
||||
#[cfg(debug_assertions)]
|
||||
use super::send_track_events_request;
|
||||
use super::track_event_request_batches;
|
||||
use crate::events::CodexAcceptedLineFingerprintsEventParams;
|
||||
@@ -34,10 +36,13 @@ use codex_app_server_protocol::TurnSteerResponse;
|
||||
use codex_utils_absolute_path::test_support::PathBufExt;
|
||||
use codex_utils_absolute_path::test_support::test_path_buf;
|
||||
use std::collections::HashSet;
|
||||
#[cfg(debug_assertions)]
|
||||
use std::fs;
|
||||
#[cfg(debug_assertions)]
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
#[cfg(debug_assertions)]
|
||||
use std::time::SystemTime;
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::sync::mpsc::error::TryRecvError;
|
||||
@@ -80,6 +85,7 @@ fn sample_regular_track_event(thread_id: &str) -> TrackEventRequest {
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
fn unique_capture_path(name: &str) -> PathBuf {
|
||||
let nonce = SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
@@ -102,6 +108,7 @@ fn client_with_receiver() -> (AnalyticsEventsClient, mpsc::Receiver<AnalyticsFac
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(debug_assertions)]
|
||||
fn analytics_destination_uses_explicit_capture_file() {
|
||||
let capture_path = unique_capture_path("destination");
|
||||
let destination = AnalyticsEventsDestination::from_base_url_and_capture_file(
|
||||
@@ -147,7 +154,24 @@ fn analytics_destination_uses_http_without_capture_file() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(debug_assertions))]
|
||||
fn analytics_destination_ignores_capture_file_in_release() {
|
||||
let destination = AnalyticsEventsDestination::from_base_url_and_capture_file(
|
||||
"https://chatgpt.com/backend-api/".to_string(),
|
||||
Some(std::path::PathBuf::from("ignored.jsonl")),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
destination,
|
||||
AnalyticsEventsDestination::Http {
|
||||
url: "https://chatgpt.com/backend-api/codex/analytics-events/events".to_string()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[cfg(debug_assertions)]
|
||||
async fn capture_file_writes_exact_serialized_request() {
|
||||
let capture_path = unique_capture_path("single");
|
||||
let destination = AnalyticsEventsDestination::CaptureFile {
|
||||
@@ -170,6 +194,7 @@ async fn capture_file_writes_exact_serialized_request() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[cfg(debug_assertions)]
|
||||
async fn capture_file_writes_final_batches_as_separate_lines() {
|
||||
let capture_path = unique_capture_path("batches");
|
||||
let destination = AnalyticsEventsDestination::CaptureFile {
|
||||
@@ -203,6 +228,7 @@ async fn capture_file_writes_final_batches_as_separate_lines() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(debug_assertions)]
|
||||
fn capture_write_failure_still_consumes_delivery() {
|
||||
let capture_path = unique_capture_path("missing-parent").join("events.jsonl");
|
||||
let destination = AnalyticsEventsDestination::CaptureFile { path: capture_path };
|
||||
|
||||
@@ -68,8 +68,18 @@ pub(super) fn run(
|
||||
|
||||
let installed = plugin_installed(&mut client)?;
|
||||
let expected = expected_plugin(&installed, plugin_id)?;
|
||||
write_plugin_enabled(&mut client, temporary_config.path(), plugin_id, false)?;
|
||||
write_plugin_enabled(&mut client, temporary_config.path(), plugin_id, true)?;
|
||||
write_plugin_enabled(
|
||||
&mut client,
|
||||
temporary_config.path(),
|
||||
plugin_id,
|
||||
/*enabled*/ false,
|
||||
)?;
|
||||
write_plugin_enabled(
|
||||
&mut client,
|
||||
temporary_config.path(),
|
||||
plugin_id,
|
||||
/*enabled*/ true,
|
||||
)?;
|
||||
|
||||
let plugin_config_key = format!("plugins.{plugin_id}.enabled");
|
||||
let thread = client.thread_start(ThreadStartParams {
|
||||
|
||||
Reference in New Issue
Block a user