Merge branch 'use_mktemp' of https://github.com/golharam/arvados into golharam-use_mktemp
[arvados.git] / services / api / test / integration / noop_deep_munge_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 NoopDeepMungeTest < ActionDispatch::IntegrationTest
8   test "empty array" do
9     check({"foo" => []})
10   end
11
12   test "null in array" do
13     check({"foo" => ["foo", nil]})
14   end
15
16   test "array of nulls" do
17     check({"foo" => [nil, nil, nil]})
18   end
19
20   protected
21
22   def check(val)
23     post "/arvados/v1/container_requests",
24       params: {
25         :container_request => {
26           :name => "workflow",
27           :state => "Uncommitted",
28           :command => ["echo"],
29           :container_image => "arvados/jobs",
30           :output_path => "/",
31           :mounts => {
32             :foo => {
33               :kind => "json",
34               :content => JSON.parse(SafeJSON.dump(val)),
35             }
36           }
37         }
38       }.to_json,
39       headers: {
40         'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin).api_token}",
41         'CONTENT_TYPE' => 'application/json'
42       }
43     assert_response :success
44     assert_equal "arvados#containerRequest", json_response['kind']
45     assert_equal val, json_response['mounts']['foo']['content']
46   end
47 end