Enforce feature isolation and expand copy_count test coverage

- Gate env_logger init behind #[cfg(feature = "bin-logging")] in
  records.rs main() so the binary respects the feature flag
- Set default-features = false on the dev-dependency self-reference
  in Cargo.toml; previously default features were silently re-enabled
  during tests, making feature isolation accidental rather than real
- Bind guid.to_string() once per card in user_data.rs deck loop and
  reuse it via clone, replacing three allocations per locked card
- Add per-field help text to the Track subcommand args clarifying
  human-readable names ("Laguna Seca", "Dry") vs raw codes
- Document write_details_csv DashMap snapshot memory tradeoff
  (full clone, roughly doubled peak memory during the write)
- Extend my_cars fixture test: duplicate guids count as 2 copies
  with per-copy configs, and incomplete-tune cards still count in
  copy_count
This commit is contained in:
Jan-Peter von Hunnius 2026-08-15 21:30:38 +02:00
parent 1a844e7aa8
commit ec8be9d138
5 changed files with 35 additions and 9 deletions

View file

@ -240,6 +240,7 @@ fn test_load_my_cars_data_with_fixture() {
let json = r#"{
"playerDeck": [
{ "cardId": "guid_a", "locked": true, "engineMajor": 3, "weightMajor": 2, "chassisMajor": 3 },
{ "cardId": "guid_a", "locked": true, "engineMajor": 2, "weightMajor": 3, "chassisMajor": 3 },
{ "cardId": "guid_b", "locked": false, "engineMajor": 2, "weightMajor": 3, "chassisMajor": 3 },
{ "cardId": "guid_c", "locked": true, "engineMajor": 1, "weightMajor": 1, "chassisMajor": 1 }
],
@ -251,15 +252,19 @@ fn test_load_my_cars_data_with_fixture() {
let data = load_my_cars_data(path.to_str().unwrap()).unwrap();
// Only locked cards are owned
// Only locked cards are owned (set deduplicates duplicate guids)
assert_eq!(data.owned.len(), 2);
assert!(data.owned.contains("guid_a"));
assert!(data.owned.contains("guid_c"));
assert!(!data.owned.contains("guid_b"));
// owned_configs only for locked cards with complete tune data
assert_eq!(data.owned_configs.len(), 2);
assert_eq!(data.owned_configs.get("guid_a"), Some(&vec!["323".to_string()]));
// copy_count tracks duplicates: guid_a has two copies, guid_c one
assert_eq!(data.copy_count.get("guid_a"), Some(&2));
assert_eq!(data.copy_count.get("guid_c"), Some(&1));
assert!(!data.copy_count.contains_key("guid_b"));
// owned_configs collects one entry per copy with complete tune data
assert_eq!(data.owned_configs.get("guid_a"), Some(&vec!["323".to_string(), "233".to_string()]));
assert_eq!(data.owned_configs.get("guid_c"), Some(&vec!["111".to_string()]));
// Unlocked card should not be in owned_configs
assert!(!data.owned_configs.contains_key("guid_b"));
@ -289,6 +294,11 @@ fn test_load_my_cars_data_incomplete_tune_data() {
// All locked cards are owned
assert_eq!(data.owned.len(), 3);
// copy_count counts every locked card, even without complete tune data
assert_eq!(data.copy_count.get("guid_full"), Some(&1));
assert_eq!(data.copy_count.get("guid_partial"), Some(&1));
assert_eq!(data.copy_count.get("guid_empty"), Some(&1));
// Only the card with complete tune data has a config entry
assert_eq!(data.owned_configs.len(), 1);
assert_eq!(data.owned_configs.get("guid_full"), Some(&vec!["233".to_string()]));