fabro/lib/foundation/fabro-api/tests/model_features_round_trip.rs
Bryan Helmkamp 3c33e0fb69
Merge origin/main (three-layer crate layout) into fix/openrouter-anthropic-prompt-caching
The crate reorganization renamed lib/crates/ to lib/apps|components|foundation/.
Git followed all modified files across the rename; the only conflict was the
newly added codec/cache.rs, now placed at lib/components/fabro-llm/src/codec/cache.rs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 19:30:20 -04:00

44 lines
1.4 KiB
Rust

use std::any::{TypeId, type_name};
use fabro_api::types::ModelFeatures as ApiModelFeatures;
use fabro_model::{ModelFeatures, ReasoningEffortFeature};
#[test]
fn model_features_reuses_canonical_type() {
assert_same_type::<ApiModelFeatures, ModelFeatures>();
}
#[test]
fn model_features_json_matches_openapi_shape() {
let features = ModelFeatures {
tools: true,
vision: true,
reasoning: true,
reasoning_effort: ReasoningEffortFeature::Levels,
prompt_cache: false,
cache_control_breakpoints: false,
sampling_params: true,
};
let json = serde_json::to_value(&features).unwrap();
assert_eq!(json["tools"], true);
assert_eq!(json["vision"], true);
assert_eq!(json["reasoning"], true);
assert_eq!(json["reasoning_effort"], "levels");
assert_eq!(json["prompt_cache"], false);
assert_eq!(json["cache_control_breakpoints"], false);
assert_eq!(json["sampling_params"], true);
let round_trip: ApiModelFeatures = serde_json::from_value(json).unwrap();
assert_eq!(round_trip, features);
}
fn assert_same_type<T: 'static, U: 'static>() {
assert_eq!(
TypeId::of::<T>(),
TypeId::of::<U>(),
"{} should be the same type as {}",
type_name::<T>(),
type_name::<U>()
);
}