forked from lix-project/hydra
Projects: delete: delete all builds first
Deleting jobsets first would fail because buildmetrics has an FK to the jobset. However, the jobset / project relationship is not marked as CASCADE. Deleting all the builds automatically cascades to delete buildmetrics, so deleting the relevant builds first, then deleting the jobset solves it.
This commit is contained in:
parent
0044622198
commit
f4c4b496d8
|
@ -78,8 +78,8 @@ sub project_DELETE {
|
|||
requireProjectOwner($c, $c->stash->{project});
|
||||
|
||||
$c->model('DB')->schema->txn_do(sub {
|
||||
$c->stash->{project}->jobsets->delete;
|
||||
$c->stash->{project}->builds->delete;
|
||||
$c->stash->{project}->jobsets->delete;
|
||||
$c->stash->{project}->delete;
|
||||
});
|
||||
|
||||
|
|
|
@ -55,4 +55,21 @@ subtest "Deleting a simple project" => sub {
|
|||
);
|
||||
};
|
||||
|
||||
done_testing;
|
||||
subtest "Deleting a project with metrics" => sub {
|
||||
my $builds = $ctx->makeAndEvaluateJobset(
|
||||
expression => "runcommand.nix",
|
||||
build => 1
|
||||
);
|
||||
my $project = $builds->{"metrics"}->project;
|
||||
|
||||
my $responseAuthed = request(DELETE "/project/${\$project->name}",
|
||||
Cookie => $cookie,
|
||||
Accept => "application/json"
|
||||
);
|
||||
is($responseAuthed->code, 200, "Deleting a project with auth returns a 200");
|
||||
|
||||
my $response = request(GET "/project/${\$project->name}");
|
||||
is($response->code, 404, "Then getting the project returns a 404");
|
||||
};
|
||||
|
||||
done_testing;
|
||||
|
|
Loading…
Reference in a new issue