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:
hermes 2026-10-14 09:31:12 +00:00
commit e78d9fcecd
13 changed files with 214 additions and 161 deletions

View file

@ -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,