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