From c46cd0cd4f202ac0dcd6ee1db4ab4f19a2782b77 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Wed, 9 Nov 2022 17:10:06 +0100 Subject: [PATCH] integration_test: write config file to a temp dir, ensure it gets loaded --- integration_tests.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/integration_tests.py b/integration_tests.py index a541123..556a4f3 100644 --- a/integration_tests.py +++ b/integration_tests.py @@ -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)