Merge branch '4823-python-sdk-writable-collection-api' closes #4823
[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     skip "Waiting unitl #4534 is implemented"
11
12     uuid = Digest::MD5.hexdigest(foo_manifest) + '+' + foo_manifest.size.to_s
13     out, err = capture_subprocess_io do
14       assert_arv('--format', 'uuid', 'collection', 'create', '--collection', {
15                    uuid: uuid,
16                    manifest_text: foo_manifest
17                  }.to_json)
18     end
19     assert /^([0-9a-z]{5}-4zz18-[0-9a-z]{15})?$/.match(out)
20     assert_equal '', err
21     $stderr.puts err
22   end
23
24   protected
25   def assert_arv(*args)
26     expect = case args.first
27              when true, false
28                args.shift
29              else
30                true
31              end
32     assert_equal(expect,
33                  system(['./bin/arv', 'arv'], *args),
34                  "`arv #{args.join ' '}` " +
35                  "should exit #{if expect then 0 else 'non-zero' end}")
36   end
37
38   def foo_manifest
39     ". #{Digest::MD5.hexdigest('foo')}+3 0:3:foo\n"
40   end
41 end