mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-11-07 09:45:36 +00:00
refactor(core): compile the mock provider only with a testing feature
Phase 3a of docs/DESIGN.md. MockProvider moves to api/mock.rs, and it, the embedded MSN fixture bodies, and the IDX_MOCK_* hooks compile only with idx-core's new `testing` feature. idx-cli enables it as a dev-dependency, so `cargo test` keeps the fixture-backed provider while release binaries no longer embed fixture data or honor IDX_USE_MOCK_PROVIDER. Parser helpers used only by the mock are gated the same way. The packaged-cli flake check no longer relies on the mock; it checks an offline cache miss (JSON CACHEMISS, exit 3) instead. Goldens unchanged; clippy is clean with and without `testing`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
15947de51a
commit
e78d9fcecd
13 changed files with 214 additions and 161 deletions
|
|
@ -11,6 +11,7 @@ use client::YahooClient;
|
|||
use map::{parse_fundamentals, parse_quote};
|
||||
use parse::parse_history_with_verbose;
|
||||
|
||||
#[cfg(feature = "testing")]
|
||||
pub(crate) use parse::{
|
||||
parse_fundamentals_from_str, parse_history_from_str_with_verbose, parse_quote_from_str,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,9 +1,16 @@
|
|||
use crate::api::types::{Fundamentals, Ohlc, Quote};
|
||||
use crate::api::types::Ohlc;
|
||||
#[cfg(any(test, feature = "testing"))]
|
||||
use crate::api::types::{Fundamentals, Quote};
|
||||
use crate::error::IdxError;
|
||||
|
||||
use super::map::{parse_fundamentals, parse_history, parse_quote};
|
||||
use super::raw_types::{ChartResponse, QuoteSummaryResponse};
|
||||
use super::map::parse_history;
|
||||
#[cfg(any(test, feature = "testing"))]
|
||||
use super::map::{parse_fundamentals, parse_quote};
|
||||
use super::raw_types::ChartResponse;
|
||||
#[cfg(any(test, feature = "testing"))]
|
||||
use super::raw_types::QuoteSummaryResponse;
|
||||
|
||||
#[cfg(any(test, feature = "testing"))]
|
||||
pub(crate) fn parse_quote_from_str(symbol: &str, raw: &str) -> Result<Quote, IdxError> {
|
||||
let chart: ChartResponse =
|
||||
serde_json::from_str(raw).map_err(|e| IdxError::ParseError(e.to_string()))?;
|
||||
|
|
@ -15,6 +22,7 @@ pub(crate) fn parse_history_from_str(symbol: &str, raw: &str) -> Result<Vec<Ohlc
|
|||
parse_history_from_str_with_verbose(symbol, raw, false)
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "testing"))]
|
||||
pub(crate) fn parse_history_from_str_with_verbose(
|
||||
symbol: &str,
|
||||
raw: &str,
|
||||
|
|
@ -25,6 +33,7 @@ pub(crate) fn parse_history_from_str_with_verbose(
|
|||
parse_history_with_verbose(symbol, &chart, verbose)
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "testing"))]
|
||||
pub(crate) fn parse_fundamentals_from_str(
|
||||
symbol: &str,
|
||||
raw: &str,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue