]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add tests for GitbuilderProject._get_uri_reference
authorZack Cerza <zack@redhat.com>
Wed, 21 Sep 2016 22:21:52 +0000 (16:21 -0600)
committerZack Cerza <zack@redhat.com>
Tue, 4 Oct 2016 15:01:20 +0000 (09:01 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/test/test_packaging.py

index c54f0926dc0bc63dd0e709c2e6ebe7dcc6f1f223..fe3193fe374e6e5f292a3486c336a97cdcbf901b 100644 (file)
@@ -385,6 +385,34 @@ class TestBuilderProject(object):
         expected_log = 'More than one of ref, tag, branch, or sha1 supplied; using tag'
         assert expected_log in caplog.text()
 
+    REFERENCE_MATRIX = [
+        ('the_ref', 'the_tag', 'the_branch', 'the_sha1', 'ref/the_ref'),
+        (None, 'the_tag', 'the_branch', 'the_sha1', 'ref/the_tag'),
+        (None, None, 'the_branch', 'the_sha1', 'ref/the_branch'),
+        (None, None, None, 'the_sha1', 'sha1/the_sha1'),
+        (None, None, 'the_branch', None, 'ref/the_branch'),
+    ]
+
+    @pytest.mark.parametrize(
+        "ref, tag, branch, sha1, expected",
+        REFERENCE_MATRIX,
+    )
+    def test_uri_reference(self, ref, tag, branch, sha1, expected):
+        config = dict(
+            os_type='ubuntu',
+            os_version='16.04',
+        )
+        if ref:
+            config['ref'] = ref
+        if tag:
+            config['tag'] = tag
+        if branch:
+            config['branch'] = branch
+        if sha1:
+            config['sha1'] = sha1
+        gp = self.klass("ceph", config)
+        assert gp.uri_reference == expected
+
     def test_get_package_version_found(self):
         rem = self._get_remote()
         ctx = dict(foo="bar")