forked from lix-project/hydra
Merge pull request #951 from DeterminateSystems/delete-project
Fix deleting projects
This commit is contained in:
commit
e9a06113c9
|
@ -78,7 +78,7 @@ sub project_DELETE {
|
||||||
requireProjectOwner($c, $c->stash->{project});
|
requireProjectOwner($c, $c->stash->{project});
|
||||||
|
|
||||||
$c->model('DB')->schema->txn_do(sub {
|
$c->model('DB')->schema->txn_do(sub {
|
||||||
$c->stash->{project}->jobsetevals->delete;
|
$c->stash->{project}->jobsets->delete;
|
||||||
$c->stash->{project}->builds->delete;
|
$c->stash->{project}->builds->delete;
|
||||||
$c->stash->{project}->delete;
|
$c->stash->{project}->delete;
|
||||||
});
|
});
|
||||||
|
|
19
t/api-test.t
19
t/api-test.t
|
@ -128,4 +128,23 @@ subtest "evaluation" => sub {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
subtest "delete project" => sub {
|
||||||
|
subtest "with evaluations and builds" => sub {
|
||||||
|
my $result = request_json({ uri => "/project/sample", method => "DELETE" });
|
||||||
|
is($result->code(), 200, "DELETEing a project with evaluations and builds succeeds");
|
||||||
|
};
|
||||||
|
|
||||||
|
subtest "without evaluations and builds" => sub {
|
||||||
|
my $project = request_json({ uri => '/project/sample2', method => 'PUT', data => { displayname => "Sample2", enabled => "1", visible => "1", } });
|
||||||
|
is($project->code(), 201, "PUTting a new project creates it");
|
||||||
|
|
||||||
|
my $jobset = request_json({ uri => '/jobset/sample2/default2', method => 'PUT', data => { type => "1", flake => "github:nixos/nix", enabled => "1", visible => "1", checkinterval => "0"} });
|
||||||
|
is($jobset->code(), 201, "PUTting a new jobset creates it");
|
||||||
|
|
||||||
|
my $delete = request_json({ uri => "/project/sample2", method => "DELETE" });
|
||||||
|
is($delete->code(), 200, "DELETEing a jobset with no evaluations and builds succeeds");
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
Loading…
Reference in a new issue