From b8a5690c368bc69db4bebef73687858f9663ec94 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 12 Dec 2022 10:05:08 -0500 Subject: [PATCH] strip off spaces from git service command stdout --- .../services/git_service.py | 2 +- .../unit/test_git_service.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/spiffworkflow_backend/unit/test_git_service.py diff --git a/src/spiffworkflow_backend/services/git_service.py b/src/spiffworkflow_backend/services/git_service.py index f187a47c..f972b672 100644 --- a/src/spiffworkflow_backend/services/git_service.py +++ b/src/spiffworkflow_backend/services/git_service.py @@ -115,7 +115,7 @@ class GitService: result: subprocess.CompletedProcess[bytes] = cls.run_shell_command( command, return_success_state=False ) # type: ignore - return result.stdout.decode("utf-8") + return result.stdout.decode("utf-8").strip() @classmethod def run_shell_command( diff --git a/tests/spiffworkflow_backend/unit/test_git_service.py b/tests/spiffworkflow_backend/unit/test_git_service.py new file mode 100644 index 00000000..ad3c814f --- /dev/null +++ b/tests/spiffworkflow_backend/unit/test_git_service.py @@ -0,0 +1,18 @@ +"""Process Model.""" +from flask.app import Flask +from flask.testing import FlaskClient +from tests.spiffworkflow_backend.helpers.base_test import BaseTest + +from spiffworkflow_backend.services.git_service import GitService + + +class TestGitService(BaseTest): + + def test_strips_output_of_stdout_from_command( + self, + app: Flask, + client: FlaskClient, + with_db_and_bpmn_file_cleanup: None, + ) -> None: + output = GitService.run_shell_command_to_get_stdout(["echo", ' This output should not end in space or newline \n']) + assert output == 'This output should not end in space or newline'