Skip to content

Commit e3bf0ee

Browse files
Fix failing test_constuctor test by properly mocking GitHub API calls (#409)
1 parent c44c0b4 commit e3bf0ee

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

test/action/test_repo.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,25 @@ def _repo(
5858
)
5959

6060

61-
def test_constuctor():
62-
r = _repo(github="github.com", github_api="api.github.com")
61+
@patch("tagbot.action.repo.Github")
62+
def test_constructor(mock_github):
63+
# Mock the Github instance and its get_repo method
64+
mock_gh_instance = Mock()
65+
mock_github.return_value = mock_gh_instance
66+
mock_gh_instance.get_repo.return_value = Mock() # Mock registry repo
67+
68+
r = _repo(
69+
github="github.com", github_api="api.github.com", registry="test/registry"
70+
)
6371
assert r._gh_url == "https://github.com"
6472
assert r._gh_api == "https://api.github.com"
6573
assert r._git._github == "github.com"
66-
r = _repo(github="https://github.com", github_api="https://api.github.com")
74+
75+
r = _repo(
76+
github="https://github.com",
77+
github_api="https://api.github.com",
78+
registry="test/registry",
79+
)
6780
assert r._gh_url == "https://github.com"
6881
assert r._gh_api == "https://api.github.com"
6982
assert r._git._github == "github.com"

0 commit comments

Comments
 (0)