app resources: Fix tests

This commit is contained in:
Alexandre Aubin 2023-01-05 23:55:08 +01:00
parent e54bf2ed67
commit 02abcd41f9

View file

@ -30,7 +30,7 @@ from moulinette.utils.filesystem import (
rm, rm,
) )
from yunohost.utils.error import YunohostError from yunohost.utils.error import YunohostError, YunohostValidationError
logger = getActionLogger("yunohost.app_resources") logger = getActionLogger("yunohost.app_resources")
@ -859,7 +859,7 @@ class PortsResource(AppResource):
if infos["fixed"]: if infos["fixed"]:
if self._port_is_used(port_value): if self._port_is_used(port_value):
raise ValidationError(f"Port {port_value} is already used by another process or app.") raise YunohostValidationError(f"Port {port_value} is already used by another process or app.")
else: else:
while self._port_is_used(port_value): while self._port_is_used(port_value):
port_value += 1 port_value += 1
@ -920,6 +920,7 @@ class DatabaseAppResource(AppResource):
type = "database" type = "database"
priority = 90 priority = 90
dbtype: str = ""
default_properties: Dict[str, Any] = { default_properties: Dict[str, Any] = {
"dbtype": None, "dbtype": None,
@ -932,7 +933,8 @@ class DatabaseAppResource(AppResource):
"postgresql", "postgresql",
]: ]:
raise YunohostError( raise YunohostError(
"Specifying the type of db ('mysql' or 'postgresql') is mandatory for db resources" "Specifying the type of db ('mysql' or 'postgresql') is mandatory for db resources",
raw_msg=True
) )
# Hack so that people can write type = "mysql/postgresql" in toml but it's loaded as dbtype # Hack so that people can write type = "mysql/postgresql" in toml but it's loaded as dbtype