mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-11-07 09:45:36 +00:00
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:
parent
834e47b336
commit
054dd9df54
1 changed files with 29 additions and 23 deletions
|
|
@ -2438,15 +2438,20 @@ fn msn_screen_flags_idx_rows_behind_the_session() {
|
|||
|
||||
#[test]
|
||||
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);
|
||||
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"))
|
||||
.unwrap()
|
||||
.flat_map(|dir| fs::read_dir(dir.unwrap().path()).unwrap())
|
||||
.flat_map(|bucket| fs::read_dir(bucket.unwrap().path()).unwrap())
|
||||
.map(|file| file.unwrap().path())
|
||||
.find(|path| path.ends_with("BBCA.JK.json"))
|
||||
.find(|path| path.ends_with(file))
|
||||
.expect("cached quote");
|
||||
// 0.3.3 wrote quotes without the field; this one last traded long ago.
|
||||
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();
|
||||
let mut offline = mock_bin_with_root(&root);
|
||||
let quotes =
|
||||
run_success_json(offline.args(["--offline", "-o", "json", "stocks", "quote", "BBCA"]));
|
||||
assert_eq!(quotes[0]["behind_session"], true);
|
||||
run_success_json(offline.args(["--offline", "-o", "json", "stocks", "quote", symbol]));
|
||||
assert_eq!(quotes[0]["behind_session"], behind, "{symbol}");
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue