Add more tests

This commit is contained in:
JelNiSław 2022-06-06 00:09:42 +02:00
parent 7fd169de3f
commit 87a8aa5d96
No known key found for this signature in database
GPG key ID: EA41571A0A88E97E

View file

@ -2,34 +2,30 @@ from wulkabot.cogs import github
def test_parse_repo(): def test_parse_repo():
assert github.parse_repo("wulkanowy/sdk") == ("wulkanowy", "sdk") assert github.parse_repo("owner/repo") == ("owner", "repo")
assert github.parse_repo("sdk") is None assert github.parse_repo("repo", default_owner="owner") == ("owner", "repo")
assert github.parse_repo("sdk", default_owner="wulkanowy") == ("wulkanowy", "sdk") assert github.parse_repo("repo") is None
def test_parse_issue(): def test_parse_issue():
assert github.parse_issue("owner/repo#1") == (("owner", "repo", 1))
assert github.parse_issue("owner/repo#0") is None
assert github.parse_issue("#1", default_owner="owner", default_repo="repo") == (
("owner", "repo"),
1,
)
assert github.parse_issue("repo#1", default_owner="owner") == (("owner", "repo"), 1)
assert github.parse_issue("#1", default_owner="owner") is None
assert github.parse_issue("#1", default_repo="repo") is None
assert github.parse_issue("repo#1", default_repo="repo") is None
assert github.parse_issue("repo#1") is None
assert github.parse_issue("#1") is None assert github.parse_issue("#1") is None
assert github.parse_issue("") is None assert github.parse_issue("") is None
assert github.parse_issue("#1", default_owner="wulkanowy") is None
assert github.parse_issue("#1", default_repo="wulkanowy") is None
assert github.parse_issue("#1", default_owner="wulkanowy", default_repo="wulkanowy") == (
("wulkanowy", "wulkanowy"),
1,
)
assert github.parse_issue("wulkanowy#1") is None
assert github.parse_issue("wulkanowy#1", default_owner="wulkanowy") == (
("wulkanowy", "wulkanowy"),
1,
)
assert github.parse_issue("wulkanowy#1", default_repo="wulkanowy") is None
def test_find_repo_in_channel_topic(): def test_find_repo_in_channel_topic():
assert github.find_repo_in_channel_topic("") is None assert github.find_repo_in_channel_topic("https://github.com/owner/repo") == ("owner", "repo")
assert github.find_repo_in_channel_topic("wulkanowy/wulkanowy") is None assert github.find_repo_in_channel_topic("https://github.com/owner") is None
assert github.find_repo_in_channel_topic("https://github.com/wulkanowy/wulkanowy") == (
"wulkanowy",
"wulkanowy",
)
assert github.find_repo_in_channel_topic("https://github.com/wulkanowy") is None
assert github.find_repo_in_channel_topic("https://github.com/") is None assert github.find_repo_in_channel_topic("https://github.com/") is None
assert github.find_repo_in_channel_topic("owner/repo") is None
assert github.find_repo_in_channel_topic("") is None