[ARVADOS] updated: 20f5b178a850b029ecd501ed49e4ed0a537c1fad

git at public.curoverse.com git at public.curoverse.com
Mon Feb 9 17:37:15 EST 2015


Summary of changes:
 sdk/ruby/lib/arvados/keep.rb               |  3 +++
 sdk/ruby/test/test_keep_manifest.rb        | 37 ++++++++++++++++++++++++++++++
 services/api/test/fixtures/collections.yml |  6 ++---
 3 files changed, 43 insertions(+), 3 deletions(-)

       via  20f5b178a850b029ecd501ed49e4ed0a537c1fad (commit)
      from  e2da84c1fd9052791ed2b684741469570e09ea35 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 20f5b178a850b029ecd501ed49e4ed0a537c1fad
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Feb 9 17:34:41 2015 -0500

    5176: Fix broken fixtures, add tests.

diff --git a/sdk/ruby/lib/arvados/keep.rb b/sdk/ruby/lib/arvados/keep.rb
index 25a6ae1..ede40c3 100644
--- a/sdk/ruby/lib/arvados/keep.rb
+++ b/sdk/ruby/lib/arvados/keep.rb
@@ -138,6 +138,9 @@ module Keep
 
     def split_file_token token
       start_pos, filesize, filename = token.split(':', 3)
+      if filename.nil?
+        raise ArgumentError.new "Invalid file token '#{token}'"
+      end
       [start_pos.to_i, filesize.to_i, unescape(filename)]
     end
 
diff --git a/sdk/ruby/test/test_keep_manifest.rb b/sdk/ruby/test/test_keep_manifest.rb
index 50a3d36..8ad8134 100644
--- a/sdk/ruby/test/test_keep_manifest.rb
+++ b/sdk/ruby/test/test_keep_manifest.rb
@@ -1,5 +1,6 @@
 require "minitest/autorun"
 require "arvados/keep"
+require "yaml"
 
 def random_block(size=nil)
   sprintf("%032x+%d", rand(16 ** 32), size || rand(64 * 1024 * 1024))
@@ -182,4 +183,40 @@ class ManifestTest < Minitest::Test
     refute(manifest.has_file?("a\\040b\\040c"), "one-arg unescaped found")
     refute(manifest.has_file?(".", "a\\040b\\040c"), "two-arg unescaped found")
   end
+
+  def test_parse_all_fixtures
+    fixtures('collections').each do |name, collection|
+      parse_collection_manifest name, collection
+    end
+  end
+
+  def test_raise_on_bogus_fixture
+    assert_raises ArgumentError do
+      parse_collection_manifest('bogus collection',
+                                {'manifest_text' => ". zzz 0:\n"})
+    end
+  end
+
+  def parse_collection_manifest name, collection
+    manifest = Keep::Manifest.new(collection['manifest_text'])
+    manifest.each_file_spec do |stream_name, start_pos, file_size, file_name|
+      assert_kind_of String, stream_name
+      assert_kind_of Integer, start_pos
+      assert_kind_of Integer, file_size
+      assert_kind_of String, file_name
+      assert !stream_name.empty?, "empty stream_name in #{name} fixture"
+      assert !file_name.empty?, "empty file_name in #{name} fixture"
+    end
+  end
+
+  @@fixtures = nil
+  def fixtures name
+    return @@fixtures if @@fixtures
+    path = File.expand_path("../../../../services/api/test/fixtures/#{name}.yml",
+                            __FILE__)
+    file = IO.read(path)
+    trim_index = file.index('# Test Helper trims the rest of the file')
+    file = file[0, trim_index] if trim_index
+    @@fixtures = YAML.load(file)
+  end
 end
diff --git a/services/api/test/fixtures/collections.yml b/services/api/test/fixtures/collections.yml
index 8419178..9834716 100644
--- a/services/api/test/fixtures/collections.yml
+++ b/services/api/test/fixtures/collections.yml
@@ -60,7 +60,7 @@ baz_file:
 
 w_a_z_file:
   uuid: zzzzz-4zz18-25k12570yk134b3
-  portable_data_hash: 8706aadd12a0ebc07d74cae88762ba9e
+  portable_data_hash: 8706aadd12a0ebc07d74cae88762ba9e+56
   owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   created_at: 2015-02-09T10:53:38Z
   modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
@@ -359,12 +359,12 @@ collection_with_no_name_in_aproject:
 
 collection_to_search_for_in_aproject:
   uuid: zzzzz-4zz18-abcd6fx123409f7
-  portable_data_hash: 5bd9c1ad0bc8c7f34be170a7b7b39089+45
+  portable_data_hash: 1f4b0bc7583c2a7f9102c395f4ffc5e3+45
   owner_uuid: zzzzz-j7d0g-v955i6s2oi1cbso
   created_at: 2014-04-21 15:37:48 -0400
   modified_at: 2014-04-21 15:37:48 -0400
   updated_at: 2014-04-21 15:37:48 -0400
-  manifest_text: ". juku76584cc2f85cedef654fjyhtgimh+3 0:3:foo\n"
+  manifest_text: ". acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:foo\n"
   name: "zzzzz-4zz18-abcd6fx123409f7 used to search with any"
 
 upload_sandbox:

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list