Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jx2lee committed Oct 22, 2024
1 parent 2a492c7 commit a0689b0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/unit/clients/test_git.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import unittest
from unittest.mock import MagicMock, patch

from dbt.clients.git import list_tags


class Git(unittest.TestCase):
@patch("dbt_common.clients.system.run_cmd")
@patch("subprocess.Popen")
def test_list_tags(self, mock_popen, mock_run_cmd):
mock_process = MagicMock()
mock_process.returncode = 0
mock_process.communicate.return_value = (b"v1.0.0\nv1.1.0\nv2.0.0\n", b"")
mock_popen.return_value = mock_process

cwd = "/path/to/repo"
tags = list_tags(cwd)

self.assertEqual(tags, ["v1.0.0", "v1.1.0", "v2.0.0"])

0 comments on commit a0689b0

Please sign in to comment.