Skip to content

Commit 36aa334

Browse files
committed
fixup! feat: add prune_db command to prune old checkouts, builds and tests. * Delete rows older than a given age with manual cascade (checkout -> builds -> tests) * --origins scoping, --dry-run and a --yes confirmation. Extract parse_interval into a shared helper and add integration tests.
* Add tables parameter. * Protect issue related rows by default, and add parameter to bypass. Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
1 parent 3eabbe3 commit 36aa334

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

backend/kernelCI_app/tests/integrationTests/prune_db_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test_tables_tests_only():
135135
build = BuildFactory(checkout=checkout, field_timestamp=_days_ago(30))
136136
test = TestFactory(build=build, field_timestamp=_days_ago(30))
137137

138-
_prune(yes=True, tables="tests")
138+
_prune(yes=True, tables=["tests"])
139139

140140
assert Checkouts.objects.filter(id=checkout.id).exists()
141141
assert Builds.objects.filter(id=build.id).exists()
@@ -148,7 +148,7 @@ def test_tables_builds_only():
148148
build = BuildFactory(checkout=checkout, field_timestamp=_days_ago(30))
149149
test = TestFactory(build=build, field_timestamp=_days_ago(30))
150150

151-
_prune(yes=True, tables="builds")
151+
_prune(yes=True, tables=["builds"])
152152

153153
assert Checkouts.objects.filter(id=checkout.id).exists()
154154
assert not Builds.objects.filter(id=build.id).exists()
@@ -158,7 +158,7 @@ def test_tables_builds_only():
158158
@pytest.mark.django_db
159159
def test_invalid_table():
160160
with pytest.raises(CommandError, match="Unknown table"):
161-
_prune(yes=True, tables="incidents")
161+
_prune(yes=True, tables=["incidents"])
162162

163163

164164
@pytest.mark.django_db

0 commit comments

Comments
 (0)