mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-02-22 21:25:43 -05:00
add integration_tests.py
This commit is contained in:
parent
daff20302a
commit
c027afd58a
1 changed files with 46 additions and 0 deletions
46
integration_tests.py
Normal file
46
integration_tests.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
import click
|
||||
import os
|
||||
import pytest
|
||||
|
||||
from glob import glob
|
||||
|
||||
from config import config, CONFIG_DEFAULTS
|
||||
from constants import SRCINFO_METADATA_FILE
|
||||
from exec.file import get_temp_dir
|
||||
from logger import setup_logging
|
||||
from packages.cli import cmd_clean, cmd_update
|
||||
from utils import git_get_branch
|
||||
|
||||
tempdir = None
|
||||
config.try_load_file()
|
||||
setup_logging(True)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def ctx() -> click.Context:
|
||||
global tempdir
|
||||
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})
|
||||
print(f'cache_dir: {config.file.paths.cache_dir}')
|
||||
return click.Context(click.Command('integration_tests'))
|
||||
|
||||
|
||||
def test_packages_update(ctx: click.Context):
|
||||
kbs_branch = git_get_branch(config.runtime.script_source_dir)
|
||||
for branch, may_fail in {'main': False, 'dev': False, kbs_branch: True}.items():
|
||||
config.file.pkgbuilds.git_branch = branch
|
||||
try:
|
||||
ctx.invoke(cmd_update, non_interactive=True)
|
||||
print("WOULD CTX INVOKE UPDATE HERE")
|
||||
except Exception as ex:
|
||||
if not may_fail:
|
||||
print(f'Exception: {ex}')
|
||||
assert may_fail
|
||||
|
||||
|
||||
def test_packages_clean(ctx: click.Context):
|
||||
if not glob(os.path.join(config.get_path('pkgbuilds'), '*', '*', SRCINFO_METADATA_FILE)):
|
||||
ctx.invoke(cmd_update, non_interactive=True)
|
||||
ctx.invoke(cmd_clean, what=['git'], force=True)
|
Loading…
Add table
Reference in a new issue