Merge branch '8784-dir-listings'
[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          {
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, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:admin).api_token}",
39                     'CONTENT_TYPE' => 'application/json'}
40     assert_response :success
41     assert_equal "arvados#containerRequest", json_response['kind']
42     assert_equal val, json_response['mounts']['foo']['content']
43   end
44 end