]> git.ipfire.org Git - pbs.git/commitdiff
tests: Create build from source package
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 12 Oct 2022 17:51:00 +0000 (17:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 12 Oct 2022 17:51:00 +0000 (17:51 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/build.py
tests/test.py

index 966108941a38330260b6972845cf4d0d198bc626..4c1c0b58961c350289b502e629569dc3c8a83f06 100755 (executable)
@@ -4,10 +4,28 @@ import unittest
 
 import test
 
+from buildservice import builds
+
 class BuildTestCase(test.TestCase):
        """
                Tests everything around builds
        """
+       async def test_create_from_source(self):
+               """
+                       Tests whether we can create a build from a source package
+               """
+               path = self.source_path("tests/data/beep-1.3-2.ip3.src.pfm")
+
+               # Create the build
+               with self.db.transaction():
+                       build = await self._create_build(path)
+
+               # Check if any jobs have been created
+               self.assertTrue(build.jobs)
+
+               # Check if a job for each architecture has been generated
+               self.assertEqual([j.arch for j in build.jobs], self.distro.arches)
+
        async def test_create_from_binary(self):
                """
                        Tests whether we can create a build from a binary package
index b710976072fa532bfbff6530c6ac3b42148edfab..cd832777037cf4e21e435fb271c1f021664209ea 100644 (file)
@@ -10,6 +10,7 @@ import unittest
 from pakfire._pakfire import Archive
 
 from buildservice import Backend
+from buildservice import builds
 from buildservice import database
 from buildservice import misc
 from buildservice import packages
@@ -145,3 +146,22 @@ class TestCase(unittest.IsolatedAsyncioTestCase):
                self.assertIsInstance(package, packages.Package)
 
                return package
+
+       async def _create_build(self, path, repo=None, owner=None):
+               """
+                       Helper function to import a build from path
+               """
+               # Use the default repository if none set
+               if repo is None:
+                       repo = self.repo
+
+               # Import the package first
+               package = await self._create_package(path)
+
+               # Create the build
+               build = self.backend.builds.create(repo, package, owner=owner)
+
+               # Check if we received the correct type
+               self.assertIsInstance(build, builds.Build)
+
+               return build