From d0682c804dd32d753482bc73c98fb5fa48b006b7 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Fri, 30 Apr 2021 10:42:38 -0700 Subject: [PATCH 1/2] api-test: test deleting a project As of this commit, this test will fail, because the underlying cause hasn't been fixed. --- t/api-test.t | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/t/api-test.t b/t/api-test.t index 97e87bcd..ac1e4964 100644 --- a/t/api-test.t +++ b/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; From 7c9ed6b919d4113d5ecf9e189149f3edb062778c Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Fri, 30 Apr 2021 10:43:21 -0700 Subject: [PATCH 2/2] Project: fix DELETE route This appears to have been broken in ac3e8a4a5920797ce04f1fbc0fe8beb086a2472a, which removed the `jobsetevals` column from the Projects schema, but didn't update the Controller accordingly. Fixes the test added in the previous commit. --- src/lib/Hydra/Controller/Project.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Hydra/Controller/Project.pm b/src/lib/Hydra/Controller/Project.pm index f02dcc34..961ce837 100644 --- a/src/lib/Hydra/Controller/Project.pm +++ b/src/lib/Hydra/Controller/Project.pm @@ -78,7 +78,7 @@ sub project_DELETE { requireProjectOwner($c, $c->stash->{project}); $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}->delete; });