635 lines
19 KiB
Rust
635 lines
19 KiB
Rust
//! End-to-end binary integration tests for `curate-etl curate-bars-1m` (`M2.3n`).
|
|
|
|
use std::collections::BTreeMap;
|
|
use std::fs;
|
|
use std::path::{Path, PathBuf};
|
|
use std::process::{Command, Output};
|
|
use std::sync::atomic::{AtomicU64, Ordering};
|
|
|
|
use bson::raw::{cstr, RawDocumentBuf};
|
|
use curate_etl::{
|
|
et_to_utc_micros, format_curate_bars_1m_report, run_curate_bars_1m, ymd_to_epoch_days,
|
|
BsonStreamOptions, CurateBars1mArgs, IlpWriterOptions, DEFAULT_BARS_1M_MAPPING_SOURCE,
|
|
};
|
|
|
|
static TEST_DIR_SEQ: AtomicU64 = AtomicU64::new(0);
|
|
|
|
struct TempDir {
|
|
path: PathBuf,
|
|
}
|
|
|
|
impl TempDir {
|
|
fn new(tag: &str) -> Self {
|
|
let pid = std::process::id();
|
|
let seq = TEST_DIR_SEQ.fetch_add(1, Ordering::Relaxed);
|
|
let path =
|
|
std::env::temp_dir().join(format!("curate-etl-it-bars-1m-{tag}-{pid}-{seq}"));
|
|
let _ = fs::remove_dir_all(&path);
|
|
fs::create_dir_all(&path).expect("create integration test temp dir");
|
|
Self { path }
|
|
}
|
|
|
|
fn path(&self) -> &Path {
|
|
&self.path
|
|
}
|
|
}
|
|
|
|
impl Drop for TempDir {
|
|
fn drop(&mut self) {
|
|
let _ = fs::remove_dir_all(&self.path);
|
|
}
|
|
}
|
|
|
|
fn run_bin(args: &[&str]) -> Output {
|
|
Command::new(env!("CARGO_BIN_EXE_curate-etl"))
|
|
.args(args)
|
|
.output()
|
|
.expect("spawn curate-etl binary")
|
|
}
|
|
|
|
fn day(y: i32, m: u32, d: u32) -> i32 {
|
|
ymd_to_epoch_days(y, m, d).expect("valid date")
|
|
}
|
|
|
|
fn et_ts_sec(y: i32, m: u32, d: u32, hour: u8, minute: u8) -> i64 {
|
|
let micros = et_to_utc_micros(day(y, m, d), hour, minute, 0).expect("valid ET timestamp");
|
|
assert_eq!(micros % 1_000_000, 0);
|
|
micros / 1_000_000
|
|
}
|
|
|
|
fn make_intraday_doc(
|
|
code: &str,
|
|
timestamp_sec: i64,
|
|
open: f64,
|
|
high: f64,
|
|
low: f64,
|
|
close: f64,
|
|
volume: f64,
|
|
) -> RawDocumentBuf {
|
|
let mut doc = RawDocumentBuf::new();
|
|
doc.append(cstr!("eodSearchCode"), code);
|
|
doc.append(cstr!("timestamp"), timestamp_sec);
|
|
doc.append(cstr!("open"), open);
|
|
doc.append(cstr!("high"), high);
|
|
doc.append(cstr!("low"), low);
|
|
doc.append(cstr!("close"), close);
|
|
doc.append(cstr!("volume"), volume);
|
|
doc
|
|
}
|
|
|
|
fn make_split_doc(
|
|
qm_search_code: &str,
|
|
ex_date: &str,
|
|
for_factor: f64,
|
|
to_factor: f64,
|
|
) -> RawDocumentBuf {
|
|
let mut doc = RawDocumentBuf::new();
|
|
doc.append(cstr!("qmSearchCode"), qm_search_code);
|
|
doc.append(cstr!("date"), ex_date);
|
|
doc.append(cstr!("forfactor"), for_factor);
|
|
doc.append(cstr!("tofactor"), to_factor);
|
|
doc.append(cstr!("splitratio"), for_factor / to_factor);
|
|
doc
|
|
}
|
|
|
|
fn concat_docs(docs: &[RawDocumentBuf]) -> Vec<u8> {
|
|
let mut out = Vec::new();
|
|
for doc in docs {
|
|
out.extend_from_slice(doc.as_bytes());
|
|
}
|
|
out
|
|
}
|
|
|
|
fn read_dir_files(dir: &Path) -> BTreeMap<String, Vec<u8>> {
|
|
let mut out = BTreeMap::new();
|
|
for entry in fs::read_dir(dir).expect("read output dir") {
|
|
let entry = entry.expect("dir entry");
|
|
let name = entry
|
|
.file_name()
|
|
.into_string()
|
|
.expect("UTF-8 file name in output dir");
|
|
let bytes = fs::read(entry.path()).expect("read output file");
|
|
out.insert(name, bytes);
|
|
}
|
|
out
|
|
}
|
|
|
|
fn strip_timing_line(report: &str) -> Vec<&str> {
|
|
report
|
|
.lines()
|
|
.filter(|line| !line.trim_start().starts_with("timing:"))
|
|
.collect()
|
|
}
|
|
|
|
#[test]
|
|
fn curate_bars_1m_binary_matches_direct_runner_bytes_and_report() {
|
|
let tmp = TempDir::new("parity");
|
|
|
|
// Pin NVDA 10:1 forward split (2024-06-10) and NEXM 1:20 reverse split (2025-06-20)
|
|
// fixtures in the style of src/run_curate_bars_1m_tests.rs.
|
|
let intraday_path = tmp.path().join("eodIntraday1M.bson");
|
|
let intraday_bytes = concat_docs(&[
|
|
// NVDA pre-split (2024-06-07): 10:1 split un-adjusts prices x10 and volume /10.
|
|
make_intraday_doc(
|
|
"NVDA.US",
|
|
et_ts_sec(2024, 6, 7, 15, 59),
|
|
120.50,
|
|
121.00,
|
|
120.40,
|
|
120.888,
|
|
412_390.0,
|
|
),
|
|
// NVDA ex-date (2024-06-10): already post-split (factor = 1.0).
|
|
make_intraday_doc(
|
|
"NVDA.US",
|
|
et_ts_sec(2024, 6, 10, 15, 59),
|
|
121.50,
|
|
122.00,
|
|
121.20,
|
|
121.79,
|
|
350_000.0,
|
|
),
|
|
// NEXM pre-split (2025-06-18): 1:20 reverse split un-adjusts prices x0.05 and volume x20.
|
|
make_intraday_doc(
|
|
"NEXM.V",
|
|
et_ts_sec(2025, 6, 18, 15, 59),
|
|
24.20,
|
|
24.40,
|
|
24.10,
|
|
24.29,
|
|
5_000.0,
|
|
),
|
|
// NEXM ex-date (2025-06-20): already post-split (factor = 1.0).
|
|
make_intraday_doc(
|
|
"NEXM.V",
|
|
et_ts_sec(2025, 6, 20, 15, 59),
|
|
24.10,
|
|
24.35,
|
|
24.00,
|
|
24.28,
|
|
12_500.0,
|
|
),
|
|
]);
|
|
fs::write(&intraday_path, &intraday_bytes).expect("write intraday bson");
|
|
|
|
let splits_path = tmp.path().join("qmSplits.bson");
|
|
let splits_bytes = concat_docs(&[
|
|
make_split_doc("NVDA", "2024-06-10", 1.0, 10.0),
|
|
make_split_doc("NEXM:CA", "2025-06-20", 20.0, 1.0),
|
|
]);
|
|
fs::write(&splits_path, &splits_bytes).expect("write splits bson");
|
|
|
|
let mapping_path = tmp.path().join("provider_mapping.tsv");
|
|
fs::write(
|
|
&mapping_path,
|
|
"eod\tNVDA.US\t2000-01-01\t\t1001\n\
|
|
qm\tNVDA\t2000-01-01\t\t1001\n\
|
|
eod\tNEXM.V\t2000-01-01\t\t2002\n\
|
|
qm\tNEXM:CA\t2000-01-01\t\t2002\n",
|
|
)
|
|
.expect("write provider_mapping.tsv");
|
|
|
|
let known_at_micros: i64 = 1_750_000_000_000_000;
|
|
let shard_count: usize = 2;
|
|
|
|
let bin_out = tmp.path().join("out-bin");
|
|
let direct_out = tmp.path().join("out-direct");
|
|
|
|
let output = run_bin(&[
|
|
"curate-bars-1m",
|
|
"--eod-intraday",
|
|
intraday_path.to_str().unwrap(),
|
|
"--qm-splits",
|
|
splits_path.to_str().unwrap(),
|
|
"--provider-mapping",
|
|
mapping_path.to_str().unwrap(),
|
|
"--out",
|
|
bin_out.to_str().unwrap(),
|
|
"--shards",
|
|
"2",
|
|
"--known-at-micros",
|
|
"1750000000000000",
|
|
]);
|
|
|
|
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
assert!(
|
|
output.status.success(),
|
|
"expected exit 0, got {:?}; stderr:\n{stderr}\nstdout:\n{stdout}",
|
|
output.status.code()
|
|
);
|
|
assert!(
|
|
stderr.is_empty(),
|
|
"expected empty stderr on success, got:\n{stderr}"
|
|
);
|
|
|
|
let direct_args = CurateBars1mArgs {
|
|
intraday_path,
|
|
splits_path,
|
|
provider_mapping_path: mapping_path,
|
|
out_dir: direct_out.clone(),
|
|
mapping_source: DEFAULT_BARS_1M_MAPPING_SOURCE.to_string(),
|
|
shard_count,
|
|
known_at_micros,
|
|
stream_options: BsonStreamOptions::default(),
|
|
ilp_options: IlpWriterOptions::default(),
|
|
};
|
|
let direct_report = run_curate_bars_1m(&direct_args).expect("direct run_curate_bars_1m");
|
|
assert_eq!(
|
|
direct_report.rows_written, 4,
|
|
"expected 4 emitted bars_1m rows"
|
|
);
|
|
|
|
let direct_formatted = format_curate_bars_1m_report(&direct_report);
|
|
assert_eq!(
|
|
strip_timing_line(&stdout),
|
|
strip_timing_line(&direct_formatted),
|
|
"binary stdout report should match direct runner report excluding timing line"
|
|
);
|
|
assert!(
|
|
stdout
|
|
.lines()
|
|
.any(|line| line.trim_start().starts_with("timing: elapsed_secs=")),
|
|
"expected timing line in stdout:\n{stdout}"
|
|
);
|
|
|
|
let bin_files = read_dir_files(&bin_out);
|
|
let direct_files = read_dir_files(&direct_out);
|
|
|
|
let expected_names: Vec<String> = vec![
|
|
"bars_1m.shard-00.ilp".to_string(),
|
|
"bars_1m.shard-01.ilp".to_string(),
|
|
];
|
|
assert_eq!(
|
|
bin_files.keys().cloned().collect::<Vec<_>>(),
|
|
expected_names,
|
|
"unexpected files in binary output dir"
|
|
);
|
|
assert_eq!(
|
|
bin_files, direct_files,
|
|
"binary shard files must be byte-identical to direct runner output"
|
|
);
|
|
assert!(
|
|
bin_files.values().map(Vec::len).sum::<usize>() > 0,
|
|
"expected non-empty ILP output across shards"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn curate_bars_1m_binary_missing_input_exits_nonzero_and_leaves_out_clean() {
|
|
let tmp = TempDir::new("missing-input");
|
|
|
|
let missing_intraday = tmp.path().join("does-not-exist.bson");
|
|
let splits_path = tmp.path().join("qmSplits.bson");
|
|
fs::write(&splits_path, concat_docs(&[])).expect("write empty splits bson");
|
|
|
|
let mapping_path = tmp.path().join("provider_mapping.tsv");
|
|
fs::write(&mapping_path, "eod\tNVDA.US\t2000-01-01\t\t1001\n")
|
|
.expect("write provider_mapping.tsv");
|
|
|
|
let out_dir = tmp.path().join("out-empty");
|
|
fs::create_dir_all(&out_dir).expect("create empty out dir");
|
|
|
|
let output = run_bin(&[
|
|
"curate-bars-1m",
|
|
"--eod-intraday",
|
|
missing_intraday.to_str().unwrap(),
|
|
"--qm-splits",
|
|
splits_path.to_str().unwrap(),
|
|
"--provider-mapping",
|
|
mapping_path.to_str().unwrap(),
|
|
"--out",
|
|
out_dir.to_str().unwrap(),
|
|
"--shards",
|
|
"2",
|
|
"--known-at-micros",
|
|
"1750000000000000",
|
|
]);
|
|
|
|
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
assert!(
|
|
!output.status.success(),
|
|
"expected non-zero exit when intraday file is missing"
|
|
);
|
|
assert!(
|
|
stdout.is_empty(),
|
|
"expected no success report on stdout, got:\n{stdout}"
|
|
);
|
|
assert!(
|
|
stderr.contains("error:") && stderr.contains("failed to open eod-intraday"),
|
|
"expected input-open error on stderr, got:\n{stderr}"
|
|
);
|
|
|
|
let remaining = read_dir_files(&out_dir);
|
|
assert!(
|
|
remaining.is_empty(),
|
|
"expected no shard or staging files in output dir, found: {:?}",
|
|
remaining.keys().collect::<Vec<_>>()
|
|
);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// QA edge cases (T-186): binary-level behaviour not covered by the parity tests.
|
|
// ---------------------------------------------------------------------------
|
|
|
|
struct Fixture {
|
|
intraday: PathBuf,
|
|
splits: PathBuf,
|
|
mapping: PathBuf,
|
|
}
|
|
|
|
/// NVDA 10:1 split fixture: one pre-split bar (2024-06-07) and one ex-date bar (2024-06-10).
|
|
fn write_nvda_fixture(dir: &Path) -> Fixture {
|
|
let intraday = dir.join("eodIntraday1M.bson");
|
|
fs::write(
|
|
&intraday,
|
|
concat_docs(&[
|
|
make_intraday_doc(
|
|
"NVDA.US",
|
|
et_ts_sec(2024, 6, 7, 15, 59),
|
|
120.50,
|
|
121.00,
|
|
120.40,
|
|
120.75,
|
|
412_390.0,
|
|
),
|
|
make_intraday_doc(
|
|
"NVDA.US",
|
|
et_ts_sec(2024, 6, 10, 15, 59),
|
|
121.50,
|
|
122.00,
|
|
121.20,
|
|
121.75,
|
|
350_000.0,
|
|
),
|
|
]),
|
|
)
|
|
.expect("write intraday bson");
|
|
let splits = dir.join("qmSplits.bson");
|
|
fs::write(&splits, concat_docs(&[make_split_doc("NVDA", "2024-06-10", 1.0, 10.0)]))
|
|
.expect("write splits bson");
|
|
let mapping = dir.join("provider_mapping.tsv");
|
|
fs::write(
|
|
&mapping,
|
|
"eod\tNVDA.US\t2000-01-01\t\t1001\nqm\tNVDA\t2000-01-01\t\t1001\n",
|
|
)
|
|
.expect("write provider_mapping.tsv");
|
|
Fixture {
|
|
intraday,
|
|
splits,
|
|
mapping,
|
|
}
|
|
}
|
|
|
|
fn bin_args<'a>(
|
|
fx: &'a Fixture,
|
|
out: &'a Path,
|
|
known_at: &'a str,
|
|
extra: &[&'a str],
|
|
) -> Vec<&'a str> {
|
|
let mut argv = vec![
|
|
"curate-bars-1m",
|
|
"--eod-intraday",
|
|
fx.intraday.to_str().unwrap(),
|
|
"--qm-splits",
|
|
fx.splits.to_str().unwrap(),
|
|
"--provider-mapping",
|
|
fx.mapping.to_str().unwrap(),
|
|
"--out",
|
|
out.to_str().unwrap(),
|
|
"--shards",
|
|
"2",
|
|
"--known-at-micros",
|
|
known_at,
|
|
];
|
|
argv.extend_from_slice(extra);
|
|
argv
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
struct IlpRow {
|
|
listing_id: i32,
|
|
open: f64,
|
|
high: f64,
|
|
low: f64,
|
|
close: f64,
|
|
volume: f64,
|
|
known_at: i64,
|
|
ts: i64,
|
|
}
|
|
|
|
/// Minimal ILP v2 `bars_1m` decoder (binary DOUBLE fields, `known_at=<i64>t`, `<ts>t\n`).
|
|
fn decode_rows(data: &[u8]) -> Vec<IlpRow> {
|
|
let mut rows = Vec::new();
|
|
let mut i = 0usize;
|
|
while i < data.len() {
|
|
let tag_start = i;
|
|
while data[i] != b' ' {
|
|
i += 1;
|
|
}
|
|
let tags = std::str::from_utf8(&data[tag_start..i]).unwrap();
|
|
i += 1;
|
|
let listing_id: i32 = tags
|
|
.split(',')
|
|
.find_map(|t| t.strip_prefix("listing_id="))
|
|
.expect("listing_id tag")
|
|
.parse()
|
|
.unwrap();
|
|
let mut read_f64 = |name: &str| -> f64 {
|
|
let prefix = format!("{name}==");
|
|
assert!(data[i..].starts_with(prefix.as_bytes()), "expected {prefix}");
|
|
i += prefix.len() + 1; // skip binary DOUBLE type tag
|
|
let v = f64::from_le_bytes(data[i..i + 8].try_into().unwrap());
|
|
i += 8;
|
|
if data[i] == b',' {
|
|
i += 1;
|
|
}
|
|
v
|
|
};
|
|
let open = read_f64("open");
|
|
let high = read_f64("high");
|
|
let low = read_f64("low");
|
|
let close = read_f64("close");
|
|
let volume = read_f64("volume");
|
|
assert!(data[i..].starts_with(b"known_at="), "expected known_at=");
|
|
i += b"known_at=".len();
|
|
let ks = i;
|
|
while data[i] != b' ' {
|
|
i += 1;
|
|
}
|
|
let known_at: i64 = std::str::from_utf8(&data[ks..i])
|
|
.unwrap()
|
|
.strip_suffix('t')
|
|
.unwrap()
|
|
.parse()
|
|
.unwrap();
|
|
i += 1;
|
|
let ts_start = i;
|
|
while data[i] != b'\n' {
|
|
i += 1;
|
|
}
|
|
let ts: i64 = std::str::from_utf8(&data[ts_start..i])
|
|
.unwrap()
|
|
.strip_suffix('t')
|
|
.unwrap()
|
|
.parse()
|
|
.unwrap();
|
|
i += 1;
|
|
rows.push(IlpRow {
|
|
listing_id,
|
|
open,
|
|
high,
|
|
low,
|
|
close,
|
|
volume,
|
|
known_at,
|
|
ts,
|
|
});
|
|
}
|
|
rows
|
|
}
|
|
|
|
fn assert_close(actual: f64, expected: f64, what: &str) {
|
|
assert!(
|
|
(actual - expected).abs() <= 1e-9 * expected.abs().max(1.0),
|
|
"{what}: expected {expected}, got {actual}"
|
|
);
|
|
}
|
|
|
|
fn shard_and_staging_files(dir: &Path) -> Vec<String> {
|
|
if !dir.exists() {
|
|
return Vec::new();
|
|
}
|
|
read_dir_files(dir).into_keys().collect()
|
|
}
|
|
|
|
#[test]
|
|
fn curate_bars_1m_binary_writes_known_at_verbatim_and_unadjusts_nvda_split() {
|
|
let tmp = TempDir::new("values");
|
|
let fx = write_nvda_fixture(tmp.path());
|
|
let out = tmp.path().join("out");
|
|
|
|
let output = run_bin(&bin_args(&fx, &out, "1700000000123456", &[]));
|
|
assert!(
|
|
output.status.success(),
|
|
"stderr: {}",
|
|
String::from_utf8_lossy(&output.stderr)
|
|
);
|
|
|
|
let mut rows: Vec<IlpRow> = read_dir_files(&out)
|
|
.values()
|
|
.flat_map(|bytes| decode_rows(bytes))
|
|
.collect();
|
|
rows.sort_by_key(|r| r.ts);
|
|
assert_eq!(rows.len(), 2, "rows: {rows:?}");
|
|
|
|
for row in &rows {
|
|
assert_eq!(row.listing_id, 1001);
|
|
assert_eq!(row.known_at, 1_700_000_000_123_456, "known_at must be verbatim");
|
|
}
|
|
|
|
let pre = &rows[0];
|
|
assert_eq!(pre.ts, et_ts_sec(2024, 6, 7, 15, 59) * 1_000_000);
|
|
assert_close(pre.open, 1205.0, "pre-split open x10");
|
|
assert_close(pre.high, 1210.0, "pre-split high x10");
|
|
assert_close(pre.low, 1204.0, "pre-split low x10");
|
|
assert_close(pre.close, 1207.5, "pre-split close x10");
|
|
assert_close(pre.volume, 41_239.0, "pre-split volume /10");
|
|
|
|
let ex = &rows[1];
|
|
assert_eq!(ex.ts, et_ts_sec(2024, 6, 10, 15, 59) * 1_000_000);
|
|
assert_close(ex.close, 121.75, "ex-date close unchanged");
|
|
assert_close(ex.volume, 350_000.0, "ex-date volume unchanged");
|
|
}
|
|
|
|
#[test]
|
|
fn curate_bars_1m_binary_is_deterministic_across_runs() {
|
|
let tmp = TempDir::new("determinism");
|
|
let fx = write_nvda_fixture(tmp.path());
|
|
let out_a = tmp.path().join("out-a");
|
|
let out_b = tmp.path().join("out-b");
|
|
|
|
let a = run_bin(&bin_args(&fx, &out_a, "1750000000000000", &[]));
|
|
let b = run_bin(&bin_args(&fx, &out_b, "1750000000000000", &[]));
|
|
assert!(a.status.success() && b.status.success());
|
|
|
|
let files_a = read_dir_files(&out_a);
|
|
assert!(!files_a.is_empty());
|
|
assert_eq!(files_a, read_dir_files(&out_b), "repeat runs must be byte-identical");
|
|
assert_eq!(
|
|
strip_timing_line(&String::from_utf8_lossy(&a.stdout)),
|
|
strip_timing_line(&String::from_utf8_lossy(&b.stdout)),
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn curate_bars_1m_binary_refuses_to_overwrite_existing_shards() {
|
|
let tmp = TempDir::new("overwrite");
|
|
let fx = write_nvda_fixture(tmp.path());
|
|
let out = tmp.path().join("out");
|
|
|
|
let first = run_bin(&bin_args(&fx, &out, "1750000000000000", &[]));
|
|
assert!(first.status.success());
|
|
let before = read_dir_files(&out);
|
|
|
|
// Different known_at so any overwrite would change bytes.
|
|
let second = run_bin(&bin_args(&fx, &out, "1760000000000000", &[]));
|
|
assert!(!second.status.success(), "second run into populated --out must fail");
|
|
assert!(second.stdout.is_empty(), "no success report expected");
|
|
assert!(String::from_utf8_lossy(&second.stderr).starts_with("error:"));
|
|
assert_eq!(
|
|
read_dir_files(&out),
|
|
before,
|
|
"existing shards must be untouched and no staging files left"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn curate_bars_1m_binary_rejects_non_eod_mapping_source_without_output() {
|
|
let tmp = TempDir::new("mapping-source");
|
|
let fx = write_nvda_fixture(tmp.path());
|
|
let out = tmp.path().join("out");
|
|
|
|
let output = run_bin(&bin_args(
|
|
&fx,
|
|
&out,
|
|
"1750000000000000",
|
|
&["--mapping-source", "qm"],
|
|
));
|
|
assert!(!output.status.success());
|
|
assert!(output.stdout.is_empty());
|
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
assert!(stderr.contains("error:") && stderr.contains("qm"), "stderr: {stderr}");
|
|
assert!(
|
|
shard_and_staging_files(&out).is_empty(),
|
|
"no files expected in --out: {:?}",
|
|
shard_and_staging_files(&out)
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn curate_bars_1m_binary_parse_error_prints_usage_hides_secret_and_writes_nothing() {
|
|
let tmp = TempDir::new("parse-error");
|
|
let fx = write_nvda_fixture(tmp.path());
|
|
let out = tmp.path().join("out");
|
|
|
|
let secret = "--mongo-uri=mongodb://user:s3cr3t_pw@localhost:27017/stock";
|
|
let output = run_bin(&bin_args(&fx, &out, "1750000000000000", &[secret]));
|
|
assert!(!output.status.success());
|
|
assert!(output.stdout.is_empty());
|
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
assert!(stderr.contains("file mode only"), "stderr: {stderr}");
|
|
assert!(stderr.contains("curate-bars-1m --eod-intraday"), "usage expected: {stderr}");
|
|
assert!(!stderr.contains("s3cr3t_pw"), "secret leaked: {stderr}");
|
|
assert!(!out.exists(), "parse failure must not create --out");
|
|
|
|
// Missing --known-at-micros: no clock fallback, nothing written.
|
|
let mut argv = bin_args(&fx, &out, "1", &[]);
|
|
argv.truncate(argv.len() - 2);
|
|
let output = run_bin(&argv);
|
|
assert!(!output.status.success());
|
|
assert!(String::from_utf8_lossy(&output.stderr)
|
|
.contains("missing required flag '--known-at-micros'"));
|
|
assert!(!out.exists());
|
|
}
|