Skip to content

Commit

Permalink
frontend: add tests for branching custom directory
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyX authored and praiskup committed Apr 29, 2024
1 parent 0e1c549 commit 1e21c06
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
1 change: 1 addition & 0 deletions frontend/coprs_frontend/commands/rawhide_to_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def rawhide_to_release_function(rawhide_chroot, dest_chroot, retry_forked):
copr_chroot = turn_on_the_chroot_for_copr(copr, rawhide_chroot, mock_chroot)

for copr_dir in copr.dirs:
print("Processing directory '{}'".format(copr_dir.full_name))
data = {"projectname": copr.name,
"ownername": copr.owner_name,
"copr_dir": copr_dir.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def test_rawhide_to_release_action():
assert actions[0].appstream_shortcut != actions[1].appstream_shortcut


@pytest.mark.usefixtures("f_copr_chroots_assigned_finished")
@pytest.mark.usefixtures("f_copr_chroots_assigned_finished", "f_pr_dir",
"f_pr_build")
class TestBranchFedora(CoprsTestCase):

def _get_actions(self):
Expand Down Expand Up @@ -95,6 +96,10 @@ def test_branch_fedora(self, capsys):

db.session.add(mch_rawhide_x86_64)
db.session.add(cc_rawhide_x86_64)

# Build in a custom directory, let's pretend it was in rawhide
self.bc_pr.mock_chroot = mch_rawhide_x86_64

db.session.commit()

assert self._get_actions() == []
Expand Down Expand Up @@ -122,39 +127,62 @@ def test_branch_fedora(self, capsys):
for cch in mch.copr_chroots:
bchs += cch.build_chroots

assert len(bchs) == 1
bch = bchs[0]
assert len(bchs) == 2

assert bchs[0].status == StatusEnum("forked")
assert bchs[0].build.package == self.p3

assert bch.status == StatusEnum("forked")
assert bch.build.package == self.p3
assert bchs[1].status == StatusEnum("forked")
assert bchs[1].build.package == self.b_pr.package

assert self._get_actions() == ["rawhide_to_release", "createrepo"]
expected_actions = [
"rawhide_to_release",
"createrepo",
"rawhide_to_release",
]
assert self._get_actions() == expected_actions

# re-run the command, this is no-op
branch_fedora_function(19, False, 'f19')
assert self._get_actions() == ["rawhide_to_release", "createrepo", "createrepo"]
expected_actions += ["createrepo"]
assert self._get_actions() == expected_actions

# re-run, and re-fork all the builds, generates new action
branch_fedora_function(19, True, 'f19')
assert self._get_actions() == ["rawhide_to_release", "createrepo", "createrepo",
"rawhide_to_release", "createrepo"]
expected_actions += [
"rawhide_to_release",
"createrepo",
"rawhide_to_release"
]
assert self._get_actions() == expected_actions

stdout, _ = capsys.readouterr()
assert stdout == "\n".join([
"Handling builds in copr 'user2/barcopr', chroot 'fedora-rawhide-i386'",
"Processing directory 'user2/barcopr'",
" Fresh new build chroots: 1, regenerate 0",
"Handling builds in copr 'user1/foocopr', chroot 'fedora-rawhide-x86_64'",
"Processing directory 'user1/foocopr'",
"Createrepo for 'user1/foocopr', chroot 'fedora-19-x86_64'",
"Processing directory 'user1/foocopr:PR'",
" Fresh new build chroots: 1, regenerate 0",
"fedora-19-i386 - already exists.",
"fedora-19-x86_64 - already exists.",
"Handling builds in copr 'user2/barcopr', chroot 'fedora-rawhide-i386'",
"Processing directory 'user2/barcopr'",
"Handling builds in copr 'user1/foocopr', chroot 'fedora-rawhide-x86_64'",
"Processing directory 'user1/foocopr'",
"Createrepo for 'user1/foocopr', chroot 'fedora-19-x86_64'",
"Processing directory 'user1/foocopr:PR'",
"fedora-19-i386 - already exists.",
"fedora-19-x86_64 - already exists.",
"Handling builds in copr 'user2/barcopr', chroot 'fedora-rawhide-i386'",
"Processing directory 'user2/barcopr'",
" Fresh new build chroots: 0, regenerate 1",
"Handling builds in copr 'user1/foocopr', chroot 'fedora-rawhide-x86_64'",
"Processing directory 'user1/foocopr'",
"Createrepo for 'user1/foocopr', chroot 'fedora-19-x86_64'",
"Processing directory 'user1/foocopr:PR'",
" Fresh new build chroots: 0, regenerate 1",
""
])

0 comments on commit 1e21c06

Please sign in to comment.