Skip to content

Commit

Permalink
adding unit test coverage for gitlab provider
Browse files Browse the repository at this point in the history
  • Loading branch information
gvauter committed Sep 3, 2024
1 parent fd3080f commit 15b89f9
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tests/trestlebot/entrypoints/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from trestle.common.file_utils import is_hidden

from tests.testutils import args_dict_to_list, configure_test_logger, setup_for_init
from trestlebot.const import GITHUB, TRESTLEBOT_CONFIG_DIR, TRESTLEBOT_KEEP_FILE
from trestlebot.const import GITHUB, GITLAB, TRESTLEBOT_CONFIG_DIR, TRESTLEBOT_KEEP_FILE
from trestlebot.entrypoints.init import InitEntrypoint
from trestlebot.entrypoints.init import main as cli_main
from trestlebot.tasks.authored import types as model_types
Expand Down Expand Up @@ -132,6 +132,30 @@ def test_init_ssp_github(
)


@patch(
"trestlebot.entrypoints.log.configure_logger",
Mock(side_effect=configure_test_logger),
)
def test_init_ssp_gitlab(
tmp_init_dir: str, args_dict: Dict[str, str], caplog: pytest.LogCaptureFixture
) -> None:
"""Tests for expected logging message"""
args_dict["working-dir"] = tmp_init_dir
args_dict["oscal-model"] = OSCAL_MODEL_SSP
args_dict["provider"] = GITLAB
setup_for_init(pathlib.Path(tmp_init_dir))
with patch("sys.argv", ["trestlebot", *args_dict_to_list(args_dict)]):
with pytest.raises(SystemExit, match="0"):
cli_main()

assert any(
record.levelno == logging.WARNING
and "GitLab is not yet supported, no provider files will be created."
in record.message
for record in caplog.records
)


@patch(
"trestlebot.entrypoints.log.configure_logger",
Mock(side_effect=configure_test_logger),
Expand Down

0 comments on commit 15b89f9

Please sign in to comment.