Merge branch '6592-retry-if-cleanupfail' closes #6592
[arvados.git] / sdk / cli / test / test_arv-collection-create.rb
1 require 'minitest/autorun'
2 require 'digest/md5'
3 require 'active_support/core_ext'
4
5 class TestCollectionCreate < Minitest::Test
6   def setup
7   end
8
9   def test_small_collection
10     uuid = Digest::MD5.hexdigest(foo_manifest) + '+' + foo_manifest.size.to_s
11     out, err = capture_subprocess_io do
12       assert_arv('--format', 'uuid', 'collection', 'create', '--collection', {
13                    uuid: uuid,
14                    manifest_text: foo_manifest
15                  }.to_json)
16     end
17     assert /^([0-9a-z]{5}-4zz18-[0-9a-z]{15})?$/.match(out)
18     assert_equal '', err
19     $stderr.puts err
20   end
21
22   protected
23   def assert_arv(*args)
24     expect = case args.first
25              when true, false
26                args.shift
27              else
28                true
29              end
30     assert_equal(expect,
31                  system(['./bin/arv', 'arv'], *args),
32                  "`arv #{args.join ' '}` " +
33                  "should exit #{if expect then 0 else 'non-zero' end}")
34   end
35
36   def foo_manifest
37     ". #{Digest::MD5.hexdigest('foo')}+3 0:3:foo\n"
38   end
39 end