Skip to content

Tests: add coverage for _migrate_config — malformed input, already-migrated config, and unknown key preservation #78

@ChaseFlorell

Description

@ChaseFlorell

Problem

_migrate_config is called at the start of --start and --update. It deep-merges CONFIG_DEFAULTS into the existing config.toml and writes back any missing keys. Bugs here affect every user on every run. Key edge cases are untested:

  • Malformed config.toml: currently caught and printed, but no test verifies this
  • Already-migrated config: calling _migrate_config on a fully up-to-date config should not write the file (to avoid unnecessary disk I/O and timestamp changes)
  • Unknown user keys: keys that exist in config.toml but not in CONFIG_DEFAULTS (e.g. a user-added comment or a key from an older version) should be preserved, not dropped

Acceptance Criteria

  • Malformed config.toml produces a human-readable error message and does not crash with a raw traceback
  • _migrate_config on an already-complete config does not call save_config (no disk write)
  • User keys not in CONFIG_DEFAULTS survive a _migrate_config round-trip

Proposed Tests

  • test_migrate_config_handles_malformed_toml — write invalid TOML; assert error printed, no crash
  • test_migrate_config_no_write_when_already_complete — mock save_config; assert it is not called when config already has all keys
  • test_migrate_config_preserves_unknown_keys — add a non-default key to config; assert it is present after migration
  • test_migrate_config_adds_missing_keys — config missing a key from CONFIG_DEFAULTS; assert key is added after migration

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:mediumMedium prioritytaskAtomic unit of work, child of a feature or bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions