test(cli): a non-IDX quote is never behind the IDX session

From Pullfrog's review of 834e47b: nothing exercised the `.JK` guard on
quotes. The cache-entry test now also reads AAPL.US with an old as_of
and expects behind_session false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V3syn2fN2LNo5pvTSqc6eh
This commit is contained in:
hermes 2026-10-19 10:37:57 +00:00
commit 054dd9df54

View file

@ -2438,15 +2438,20 @@ fn msn_screen_flags_idx_rows_behind_the_session() {
#[test] #[test]
fn quote_read_from_a_0_3_3_cache_entry_is_behind_the_session() { fn quote_read_from_a_0_3_3_cache_entry_is_behind_the_session() {
let root = test_env_dir("quote-behind-session"); // IDX's session rule says nothing about other exchanges.
for (symbol, file, behind) in [
("BBCA", "BBCA.JK.json", true),
("AAPL.US", "AAPL.US.json", false),
] {
let root = test_env_dir(&format!("quote-behind-session-{symbol}"));
let mut warm = mock_bin_with_root(&root); let mut warm = mock_bin_with_root(&root);
run_success_json(warm.args(["-o", "json", "stocks", "quote", "BBCA"])); run_success_json(warm.args(["-o", "json", "stocks", "quote", symbol]));
let entry = fs::read_dir(root.join("cache")) let entry = fs::read_dir(root.join("cache"))
.unwrap() .unwrap()
.flat_map(|dir| fs::read_dir(dir.unwrap().path()).unwrap()) .flat_map(|dir| fs::read_dir(dir.unwrap().path()).unwrap())
.flat_map(|bucket| fs::read_dir(bucket.unwrap().path()).unwrap()) .flat_map(|bucket| fs::read_dir(bucket.unwrap().path()).unwrap())
.map(|file| file.unwrap().path()) .map(|file| file.unwrap().path())
.find(|path| path.ends_with("BBCA.JK.json")) .find(|path| path.ends_with(file))
.expect("cached quote"); .expect("cached quote");
// 0.3.3 wrote quotes without the field; this one last traded long ago. // 0.3.3 wrote quotes without the field; this one last traded long ago.
let mut cached: serde_json::Value = let mut cached: serde_json::Value =
@ -2458,9 +2463,10 @@ fn quote_read_from_a_0_3_3_cache_entry_is_behind_the_session() {
fs::write(&entry, cached.to_string()).unwrap(); fs::write(&entry, cached.to_string()).unwrap();
let mut offline = mock_bin_with_root(&root); let mut offline = mock_bin_with_root(&root);
let quotes = let quotes =
run_success_json(offline.args(["--offline", "-o", "json", "stocks", "quote", "BBCA"])); run_success_json(offline.args(["--offline", "-o", "json", "stocks", "quote", symbol]));
assert_eq!(quotes[0]["behind_session"], true); assert_eq!(quotes[0]["behind_session"], behind, "{symbol}");
fs::remove_dir_all(root).unwrap(); fs::remove_dir_all(root).unwrap();
}
} }
#[test] #[test]