integration_test: write config file to a temp dir, ensure it gets loaded

This commit is contained in:
InsanePrawn 2022-11-09 17:10:06 +01:00
parent 3eeeafb30f
commit c46cd0cd4f

View file

@ -21,14 +21,27 @@ setup_logging(True)
@pytest.fixture()
def ctx() -> click.Context:
global tempdir
if not tempdir:
tempdir = get_temp_dir()
if not os.environ.get('INTEGRATION_TESTS_USE_GLOBAL_CONFIG', 'false').lower() == 'true':
if not tempdir:
tempdir = get_temp_dir()
config.file.paths.update(CONFIG_DEFAULTS.paths | {'cache_dir': tempdir})
config_path = os.path.join(tempdir, 'kupferbootstrap.toml')
config.runtime.config_file = config_path
if not os.path.exists(config_path):
config.write()
config.try_load_file(config_path)
print(f'cache_dir: {config.file.paths.cache_dir}')
return click.Context(click.Command('integration_tests'))
def test_config_load(ctx: click.Context):
path = config.runtime.config_file
assert path
assert path.startswith('/tmp/')
assert os.path.exists(path)
config.enforce_config_loaded()
def test_packages_update(ctx: click.Context):
pkgbuilds_path = config.get_path('pkgbuilds')
kbs_branch = git_get_branch(config.runtime.script_source_dir)