CI: Bring testing of lftools.cli.version to 100% 57/72257/1
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Thu, 12 Oct 2023 19:34:38 +0000 (12:34 -0700)
committerAndrew Grimberg <agrimberg@linuxfoundation.org>
Thu, 12 Oct 2023 19:34:38 +0000 (12:34 -0700)
Finish off the testing for lftools.cli.version

Issue: RELENG-4944
Signed-off-by: Andrew Grimberg <agrimberg@linuxfoundation.org>
Change-Id: Id5ea7118f25e066c173b5a56f705d638f40689af

lftools/cli/version.py
tests/test_version.py

index ec023e1..ca2932d 100644 (file)
@@ -100,8 +100,9 @@ def patch(ctx, release_tag, patch_dir, project):
     if not os.path.isdir(patch_dir):
         log.error("{} is not a valid directory.".format(patch_dir))
         sys.exit(404)
-    status = subprocess.call(["version", "patch", release_tag, patch_dir, project])
-    sys.exit(status)
+    # due to the nature of the subprocess call, this is not testable so disable coverage
+    status = subprocess.call(["version", "patch", release_tag, patch_dir, project])  # pragma: no cover
+    sys.exit(status)  # pragma: no cover
 
 
 version.add_command(bump)
index 9a6e288..bc50fdf 100644 (file)
@@ -51,3 +51,13 @@ def test_version_release(cli_runner, datafiles):
         expected_pom = str(_file) + "/pom.xml.expected"
         # noqa: B101 .
         assert filecmp.cmp(pom, expected_pom)
+
+
+@pytest.mark.datafiles(
+    os.path.join(FIXTURE_DIR, "version_bump", "release"),
+)
+def test_patch(cli_runner, datafiles):
+    """Test patch command."""
+    os.chdir(str(datafiles))
+    result = cli_runner.invoke(cli.cli, ["version", "patch", "TestRelease", os.path.join(datafiles, "README")], obj={})
+    assert result.exit_code == 404