X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/65121f8db54a1ed15207d050e1f48c5fc26d646b..2b024674dd3de3485310e3b7a487d3748316b321:/services/api/test/unit/container_request_test.rb diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb index a3dd1f9835..e751d6158c 100644 --- a/services/api/test/unit/container_request_test.rb +++ b/services/api/test/unit/container_request_test.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + require 'test_helper' require 'helpers/docker_migration_helper' @@ -746,4 +750,28 @@ class ContainerRequestTest < ActiveSupport::TestCase end end end + + test "delete container_request and check its container's priority" do + act_as_user users(:active) do + cr = ContainerRequest.find_by_uuid container_requests(:running_to_be_deleted).uuid + + # initially the cr's container has priority > 0 + c = Container.find_by_uuid(cr.container_uuid) + assert_equal 1, c.priority + + # destroy the cr + assert_nothing_raised {cr.destroy} + + # the cr's container now has priority of 0 + c = Container.find_by_uuid(cr.container_uuid) + assert_equal 0, c.priority + end + end + + test "delete container_request in final state and expect no error due to before_destroy callback" do + act_as_user users(:active) do + cr = ContainerRequest.find_by_uuid container_requests(:completed).uuid + assert_nothing_raised {cr.destroy} + end + end end