Merge remote-tracking branch 'origin/master' into 15106-trgm-text-search
[arvados.git] / services / api / test / integration / pipeline_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 PipelineIntegrationTest < ActionDispatch::IntegrationTest
8   # These tests simulate the workflow of arv-run-pipeline-instance
9   # and other pipeline-running code.
10
11   def check_component_match(comp_key, comp_hash)
12     assert_response :success
13     built_json = json_response
14     built_component = built_json["components"][comp_key]
15     comp_hash.each_pair do |key, expected|
16       assert_equal(expected, built_component[key.to_s],
17                    "component's #{key} field changed")
18     end
19   end
20
21   test "creating a pipeline instance preserves required component parameters" do
22     comp_name = "test_component"
23     component = {
24       repository: "test_repo",
25       script: "test_script",
26       script_version: "test_refspec",
27       script_parameters: {},
28     }
29
30     post("/arvados/v1/pipeline_instances",
31       params: {
32         pipeline_instance: {
33           components: {comp_name => component}
34         }.to_json
35       },
36       headers: auth(:active))
37     check_component_match(comp_name, component)
38     pi_uuid = json_response["uuid"]
39
40     @response = nil
41     get("/arvados/v1/pipeline_instances/#{pi_uuid}", params: {}, headers: auth(:active))
42     check_component_match(comp_name, component)
43   end
44 end