1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
5 require 'minitest/autorun'
7 require 'active_support'
8 require 'active_support/core_ext'
11 class TestCollectionCreate < Minitest::Test
15 def test_small_collection
16 uuid = Digest::MD5.hexdigest(foo_manifest) + '+' + foo_manifest.size.to_s
18 out, err = capture_subprocess_io do
19 ok = arv('--format', 'uuid', 'collection', 'create', '--collection', {
21 manifest_text: foo_manifest
25 assert_equal(true, ok)
26 assert_match(/^([0-9a-z]{5}-4zz18-[0-9a-z]{15})?$/, out)
29 def test_collection_replace_files
31 uuid, err = capture_subprocess_io do
32 ok = arv('--format', 'uuid', 'collection', 'create', '--collection', '{}')
35 assert_equal(true, ok)
36 assert_match(/^([0-9a-z]{5}-4zz18-[0-9a-z]{15})?$/, uuid)
39 out, err = capture_subprocess_io do
40 ok = arv('--format', 'uuid',
41 'collection', 'update',
45 "/gpl.pdf": "b519d9cb706a29fc7ea24dbea2f05851+93/GNU_General_Public_License,_version_3.pdf",
49 assert_equal(true, ok)
50 assert_equal(uuid, out.strip)
53 out, err = capture_subprocess_io do
54 ok = arv('--format', 'json', 'collection', 'get', '--uuid', uuid)
57 assert_equal(true, ok)
58 assert_match(/\. 6a4ff0499484c6c79c95cd8c566bd25f\+249025.* 0:249025:gpl.pdf\\n/, out)
61 def test_read_resource_object_from_file
62 tempfile = Tempfile.new('collection')
64 tempfile.write({manifest_text: foo_manifest}.to_json)
67 out, err = capture_subprocess_io do
68 ok = arv('--format', 'uuid',
69 'collection', 'create', '--collection', tempfile.path)
72 assert_equal(true, ok)
73 assert_match(/^([0-9a-z]{5}-4zz18-[0-9a-z]{15})?$/, out)
81 system(['./bin/arv', 'arv'], *args)
85 ". #{Digest::MD5.hexdigest('foo')}+3 0:3:foo\n"