test(config): cover auto-created config directory

Agent-Logs-Url: https://github.com/rommapp/romm/sessions/0c94e1c8-0f79-4f5f-a72b-e45832906d00

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-05-08 13:54:19 +00:00
committed by GitHub
parent fdd9047b37
commit 9ef217339f
2 changed files with 6 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import glob
import json
import os
import sys
from pathlib import Path
from typing import Final, NotRequired, TypedDict
import pydash
@@ -189,16 +190,14 @@ class ConfigManager:
self._validate_config()
def _create_missing_config_file(self) -> None:
log.warning(f"Config file not found, creating an empty config at {hl(self.config_file, BLUE)}")
log.warning(
f"Config file not found, creating an empty config at {hl(self.config_file, BLUE)}"
)
try:
os.makedirs(os.path.dirname(self.config_file), exist_ok=True)
with open(self.config_file, "x"):
pass
Path(self.config_file).touch(exist_ok=True)
self._config_file_mounted = True
self._config_file_writable = os.access(self.config_file, os.W_OK)
except FileExistsError:
self._config_file_mounted = True
self._config_file_writable = os.access(self.config_file, os.W_OK)
except PermissionError:

View File

@@ -120,6 +120,7 @@ def test_missing_config_file_is_created(tmp_path):
loader = ConfigManager(str(config_file))
assert config_file.parent.exists()
assert config_file.exists()
assert config_file.read_text() == ""
assert loader.config.CONFIG_FILE_MOUNTED