aboutsummaryrefslogtreecommitdiff
path: root/infra/base-images/base-builder/detect_repo_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'infra/base-images/base-builder/detect_repo_test.py')
-rw-r--r--infra/base-images/base-builder/detect_repo_test.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/infra/base-images/base-builder/detect_repo_test.py b/infra/base-images/base-builder/detect_repo_test.py
index 21f64af44..0243b3ac5 100644
--- a/infra/base-images/base-builder/detect_repo_test.py
+++ b/infra/base-images/base-builder/detect_repo_test.py
@@ -23,6 +23,7 @@ import re
import sys
import tempfile
import unittest
+from unittest import mock
import detect_repo
@@ -36,6 +37,33 @@ import test_repos
# pylint: enable=wrong-import-position
+class TestCheckForRepoName(unittest.TestCase):
+ """Tests for check_for_repo_name."""
+
+ @mock.patch('os.path.exists', return_value=True)
+ @mock.patch('detect_repo.execute',
+ return_value=('https://github.com/google/syzkaller/', None))
+ def test_go_get_style_url(self, _, __):
+ """Tests that check_for_repo_name works on repos that were downloaded using
+ go get."""
+ self.assertTrue(detect_repo.check_for_repo_name('fake-path', 'syzkaller'))
+
+ @mock.patch('os.path.exists', return_value=True)
+ @mock.patch('detect_repo.execute',
+ return_value=('https://github.com/google/syzkaller', None))
+ def test_missing_git_and_slash_url(self, _, __):
+ """Tests that check_for_repo_name works on repos who's URLs do not end in
+ ".git" or "/"."""
+ self.assertTrue(detect_repo.check_for_repo_name('fake-path', 'syzkaller'))
+
+ @mock.patch('os.path.exists', return_value=True)
+ @mock.patch('detect_repo.execute',
+ return_value=('https://github.com/google/syzkaller.git', None))
+ def test_normal_style_repo_url(self, _, __):
+ """Tests that check_for_repo_name works on normally cloned repos."""
+ self.assertTrue(detect_repo.check_for_repo_name('fake-path', 'syzkaller'))
+
+
@unittest.skipIf(not os.getenv('INTEGRATION_TESTS'),
'INTEGRATION_TESTS=1 not set')
class DetectRepoIntegrationTest(unittest.TestCase):