Merge branch '8784-dir-listings'
[arvados.git] / services / api / test / functional / arvados / v1 / pipeline_instances_controller_test.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'test_helper'
6
7 class Arvados::V1::PipelineInstancesControllerTest < ActionController::TestCase
8
9   test 'create pipeline with components copied from template' do
10     authorize_with :active
11     post :create, {
12       pipeline_instance: {
13         pipeline_template_uuid: pipeline_templates(:two_part).uuid
14       }
15     }
16     assert_response :success
17     assert_equal(pipeline_templates(:two_part).components.to_json,
18                  assigns(:object).components.to_json)
19   end
20
21   test 'create pipeline with no template' do
22     authorize_with :active
23     post :create, {
24       pipeline_instance: {
25         components: {}
26       }
27     }
28     assert_response :success
29     assert_equal({}, assigns(:object).components)
30   end
31
32   [
33     true,
34     false
35   ].each do |cascade|
36     test "cancel a pipeline instance with cascade=#{cascade}" do
37       authorize_with :active
38       pi_uuid = pipeline_instances(:job_child_pipeline_with_components_at_level_2).uuid
39
40       post :cancel, {id: pi_uuid, cascade: cascade}
41       assert_response :success
42
43       pi = PipelineInstance.where(uuid: pi_uuid).first
44       assert_equal "Paused", pi.state
45
46       children = Job.where(uuid: ['zzzzz-8i9sb-job1atlevel3noc', 'zzzzz-8i9sb-job2atlevel3noc'])
47       children.each do |child|
48         assert_equal ("Cancelled" == child.state), cascade
49       end
50     end
51   end
52 end