mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-09 18:15:50 +00:00
Fix mock mode legacy sidecar drift
This commit is contained in:
+2
-1
@@ -153,7 +153,8 @@ scripts/test-*.sh
|
||||
scripts/run-tests.sh
|
||||
scripts/TEST_*.md
|
||||
|
||||
# Mock mode - exclude local overrides but keep the base file
|
||||
# Mock mode - exclude legacy/local sidecars; canonical state lives in runtime .env
|
||||
/mock.env
|
||||
mock.env.local
|
||||
mock.env.backup
|
||||
|
||||
|
||||
@@ -644,6 +644,10 @@ writing a separate `mock.env` sidecar when supported runtime installs already
|
||||
carry mock-mode ownership through `.env`. Mock enable/disable/status must use
|
||||
the canonical runtime `.env` path, with any install-dir `.env` probe treated as
|
||||
compatibility only.
|
||||
`scripts/toggle-mock.sh` is under the same rule: it may read legacy
|
||||
`mock.env` sidecars only to migrate existing local demo settings into the
|
||||
canonical runtime `.env`, but mode changes must write canonical `.env` files
|
||||
only and must not recreate root, dev, or runtime `mock.env` sidecars.
|
||||
That same dev-runtime boundary also owns the default mock density used for
|
||||
local demos. `scripts/toggle-mock.sh` must seed the same `PULSE_MOCK_*`
|
||||
defaults as `internal/mock.DefaultConfig`, so managed runtime toggles, local
|
||||
|
||||
@@ -37,6 +37,19 @@ assert_contains() {
|
||||
fi
|
||||
}
|
||||
|
||||
assert_file_absent() {
|
||||
local desc="$1"
|
||||
local path="$2"
|
||||
|
||||
if [[ ! -e "${path}" ]]; then
|
||||
echo "[PASS] ${desc}"
|
||||
else
|
||||
echo "[FAIL] ${desc}" >&2
|
||||
echo "Did not expect file to exist: ${path}" >&2
|
||||
((failures++))
|
||||
fi
|
||||
}
|
||||
|
||||
make_stub_hot_dev_bg() {
|
||||
local dir
|
||||
dir="$(mktemp -d)"
|
||||
@@ -211,12 +224,45 @@ EOF
|
||||
assert_contains "ensure_mock_env_file still seeds missing defaults" "${env_contents}" "PULSE_MOCK_VMS_PER_NODE=3"
|
||||
}
|
||||
|
||||
test_set_mock_mode_does_not_recreate_legacy_sidecars() {
|
||||
local state dev_env runtime_env
|
||||
state="$(mktemp -d)"
|
||||
temp_dirs+=("${state}")
|
||||
dev_env="${state}/dev/.env"
|
||||
runtime_env="${state}/runtime/.env"
|
||||
|
||||
TOGGLE_MOCK_PATH="${TOGGLE_MOCK}" \
|
||||
MOCK_ENV_OVERRIDE="${dev_env}" \
|
||||
DEV_DATA_DIR_OVERRIDE="${state}/dev" \
|
||||
RUNTIME_MOCK_ENV_OVERRIDE="${runtime_env}" \
|
||||
LEGACY_DEV_MOCK_ENV_OVERRIDE="${state}/dev/mock.env" \
|
||||
LEGACY_ROOT_MOCK_ENV_OVERRIDE="${state}/mock.env" \
|
||||
LEGACY_RUNTIME_MOCK_ENV_OVERRIDE="${state}/runtime/mock.env" \
|
||||
bash -lc '
|
||||
source "${TOGGLE_MOCK_PATH}"
|
||||
MOCK_ENV_FILE="${MOCK_ENV_OVERRIDE}"
|
||||
DEV_DATA_DIR="${DEV_DATA_DIR_OVERRIDE}"
|
||||
RUNTIME_MOCK_ENV_FILE="${RUNTIME_MOCK_ENV_OVERRIDE}"
|
||||
LEGACY_DEV_MOCK_ENV_FILE="${LEGACY_DEV_MOCK_ENV_OVERRIDE}"
|
||||
LEGACY_ROOT_MOCK_ENV_FILE="${LEGACY_ROOT_MOCK_ENV_OVERRIDE}"
|
||||
LEGACY_RUNTIME_MOCK_ENV_FILE="${LEGACY_RUNTIME_MOCK_ENV_OVERRIDE}"
|
||||
set_mock_mode true
|
||||
'
|
||||
|
||||
assert_contains "set_mock_mode writes canonical dev env" "$(cat "${dev_env}")" "PULSE_MOCK_MODE=true"
|
||||
assert_contains "set_mock_mode writes canonical runtime env" "$(cat "${runtime_env}")" "PULSE_MOCK_MODE=true"
|
||||
assert_file_absent "set_mock_mode does not recreate dev legacy mock sidecar" "${state}/dev/mock.env"
|
||||
assert_file_absent "set_mock_mode does not recreate root legacy mock sidecar" "${state}/mock.env"
|
||||
assert_file_absent "set_mock_mode does not recreate runtime legacy mock sidecar" "${state}/runtime/mock.env"
|
||||
}
|
||||
|
||||
main() {
|
||||
test_detects_managed_hot_dev_runtime
|
||||
test_managed_hot_dev_start_uses_takeover
|
||||
test_managed_hot_dev_stop_uses_control_plane
|
||||
test_ensure_mock_env_file_seeds_canonical_demo_defaults
|
||||
test_ensure_mock_env_file_migrates_legacy_sidecar
|
||||
test_set_mock_mode_does_not_recreate_legacy_sidecars
|
||||
|
||||
if (( failures > 0 )); then
|
||||
echo "Total failures: ${failures}" >&2
|
||||
|
||||
@@ -359,9 +359,6 @@ set_mock_mode() {
|
||||
set_env_value "$MOCK_ENV_FILE" "PULSE_MOCK_MODE" "$enabled"
|
||||
sync_mock_entries_to_file "$DEV_DATA_DIR/.env"
|
||||
sync_mock_entries_to_file "$RUNTIME_MOCK_ENV_FILE"
|
||||
sync_mock_entries_to_file "$LEGACY_DEV_MOCK_ENV_FILE"
|
||||
sync_mock_entries_to_file "$LEGACY_RUNTIME_MOCK_ENV_FILE"
|
||||
sync_mock_entries_to_file "$LEGACY_ROOT_MOCK_ENV_FILE"
|
||||
touch "$MOCK_ENV_FILE"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user