Merge pull request 'fix: WoodpeckerRunner#get_service fixed' (#30) from bugfix/woodpecker into master
Reviewed-on: https://hattori.ztsh.eu/iac/karl/pulls/30
This commit is contained in:
commit
b2a0ae0d47
3 changed files with 19 additions and 2 deletions
|
|
@ -46,3 +46,7 @@ target-version = "py312"
|
|||
|
||||
[tool.pytest.ini_options]
|
||||
asyncio_mode = "auto"
|
||||
log_cli = true
|
||||
log_cli_level = "INFO"
|
||||
log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
|
||||
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
||||
|
|
|
|||
|
|
@ -60,18 +60,20 @@ class WoodpeckerRunner(Thread):
|
|||
|
||||
asyncio.run(dispatch(result))
|
||||
|
||||
def get_service(self, files: list[str]) -> str | None:
|
||||
@staticmethod
|
||||
def get_service(files: list[str]) -> str | None:
|
||||
supported_files = []
|
||||
for f in files:
|
||||
f_parts = f.split("/")
|
||||
if f_parts[0] in ["compose", "files"]:
|
||||
supported_files.append(f[1])
|
||||
supported_files.append(f_parts[1])
|
||||
match len(set(supported_files)):
|
||||
case 0:
|
||||
return None
|
||||
case 1:
|
||||
return supported_files[0]
|
||||
case _:
|
||||
logger.error(f"Multiple services were provided: {', '.join(supported_files)}")
|
||||
raise Exception("Multiple services are not supported.")
|
||||
|
||||
|
||||
|
|
|
|||
11
tests/test_woodpecker.py
Normal file
11
tests/test_woodpecker.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from core import woodpecker
|
||||
|
||||
files = [".gitignore", "compose/nginx/docker-compose.yaml", "config/heimdall.kdbx", "files/nginx/cert/fullchain.mo.pem",
|
||||
"files/nginx/cert/key.mo.pem", "files/nginx/conf.d/default.conf", "files/nginx/conf.d/forge.conf",
|
||||
"files/nginx/conf.d/mqtt.conf", "files/nginx/conf.d/nextcloud.conf", "files/nginx/conf.d/zitadel.conf",
|
||||
"files/nginx/nginx.conf"]
|
||||
|
||||
|
||||
def test_get_service():
|
||||
service = woodpecker.WoodpeckerRunner.get_service(files)
|
||||
assert service == 'nginx'
|
||||
Loading…
Add table
Add a link
Reference in a new issue