Merge branch '7995-keep-balance-docs'
[arvados.git] / sdk / cli / test / test_arv-collection-create.rb
index c513be098674318d4604b2c54bd286f2974dfb65..f7a9dbe41a853412d84a1752ccae0637ef2250d4 100644 (file)
@@ -1,5 +1,7 @@
 require 'minitest/autorun'
 require 'digest/md5'
+require 'active_support/core_ext'
+require 'tempfile'
 
 class TestCollectionCreate < Minitest::Test
   def setup
@@ -13,9 +15,24 @@ class TestCollectionCreate < Minitest::Test
                    manifest_text: foo_manifest
                  }.to_json)
     end
-    assert_equal uuid+"\n", out
+    assert /^([0-9a-z]{5}-4zz18-[0-9a-z]{15})?$/.match(out)
     assert_equal '', err
-    $stderr.puts err
+  end
+
+  def test_read_resource_object_from_file
+    tempfile = Tempfile.new('collection')
+    begin
+      tempfile.write({manifest_text: foo_manifest}.to_json)
+      tempfile.close
+      out, err = capture_subprocess_io do
+        assert_arv('--format', 'uuid',
+                   'collection', 'create', '--collection', tempfile.path)
+      end
+      assert /^([0-9a-z]{5}-4zz18-[0-9a-z]{15})?$/.match(out)
+      assert_equal '', err
+    ensure
+      tempfile.unlink
+    end
   end
 
   protected