Files
hate_crack/tests/test_config_json_example.py
T
Justin Bollinger 01c6099db9 fix: single-source config.json.example, stop backfilling config.json on disk
hate_crack/config.json.example and the root copy had drifted (10 keys
missing from the packaged copy, 4 dead PassGPT keys still shipped,
hcatPath disagreeing). Replace the packaged copy with a symlink to the
root file so there is exactly one set of shipped defaults, and add a
test guard asserting the two stay identical.

Also stop writing missing keys back into the user's config.json on
load: merge defaults into the in-memory config_parser dict only. A
stale example file previously meant wrong defaults got persisted to
disk permanently; now the effective values are always whatever config.json.example
currently ships, and users are never surprised by keys silently
appearing in their config file.

Fixes #150
2026-07-28 17:25:37 -04:00

23 lines
745 B
Python

import json
import os
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ROOT_EXAMPLE = os.path.join(REPO_ROOT, "config.json.example")
PACKAGED_EXAMPLE = os.path.join(REPO_ROOT, "hate_crack", "config.json.example")
def test_packaged_example_is_symlink_to_root():
assert os.path.islink(PACKAGED_EXAMPLE), (
"hate_crack/config.json.example must be a symlink to the root "
"config.json.example so there is a single source of truth for defaults"
)
def test_packaged_and_root_examples_have_identical_content():
with open(ROOT_EXAMPLE) as f:
root_config = json.load(f)
with open(PACKAGED_EXAMPLE) as f:
packaged_config = json.load(f)
assert packaged_config == root_config