4363: Merge branch 'master' into 4363-less-filename-munging
[arvados.git] / services / api / test / integration / pipeline_test.rb
1 require 'test_helper'
2
3 class PipelineTest < ActionDispatch::IntegrationTest
4   # These tests simulate the workflow of arv-run-pipeline-instance
5   # and other pipeline-running code.
6
7   def check_component_match(comp_key, comp_hash)
8     assert_response :success
9     built_json = json_response
10     built_component = built_json["components"][comp_key]
11     comp_hash.each_pair do |key, expected|
12       assert_equal(expected, built_component[key.to_s],
13                    "component's #{key} field changed")
14     end
15   end
16
17   test "creating a pipeline instance preserves required component parameters" do
18     comp_name = "test_component"
19     component = {
20       repository: "test_repo",
21       script: "test_script",
22       script_version: "test_refspec",
23       script_parameters: {},
24     }
25
26     post("/arvados/v1/pipeline_instances",
27          {pipeline_instance: {components: {comp_name => component}}.to_json},
28          auth(:active))
29     check_component_match(comp_name, component)
30     pi_uuid = json_response["uuid"]
31
32     @response = nil
33     get("/arvados/v1/pipeline_instances/#{pi_uuid}", {}, auth(:active))
34     check_component_match(comp_name, component)
35   end
36 end