new_file allows optional :info hash to be populated
[ruby-mogilefs-client.git] / test / test_bigfile.rb
blob8cf462477e7eb0cb4f53558d587b34debe62e3f1
1 # -*- encoding: binary -*-
2 require './test/setup'
3 require 'mogilefs/bigfile'
5 class TestMogileFS__Bigfile < TestMogileFS
6   include MogileFS::Bigfile
8   def setup
9     @klass = MogileFS::MogileFS
10     super
11   end
13   def test_parser
14     expect = {:type=>"file",
15      :des=>"no description",
16      :chunks=>2,
17      :parts=>
18       [nil,
19        {:md5=>"d3b4d15c294b24d9f853e26095dfe3d0",
20         :paths=>
21          ["http://foo1:7500/dev2/0/000/144/0000144411.fid",
22           "http://foo2:7500/dev1/0/000/144/0000144411.fid"],
23         :bytes=>12},
24        {:md5=>"d3b4d15c294b24d9f853e26095dfe3d0",
25         :paths=>
26          ["http://foo4:7500/dev2/0/000/144/0000144411.fid",
27           "http://foo3:7500/dev1/0/000/144/0000144411.fid"],
28         :bytes=>6}],
29      :size=>18,
30      :filename=>"foo.tar",
31      :compressed=>false}
33     s = <<EOS
34 des no description
35 type file
36 compressed 0
37 filename foo.tar
38 chunks 2
39 size 18
41 part 1 bytes=12 md5=d3b4d15c294b24d9f853e26095dfe3d0 paths: http://foo1:7500/dev2/0/000/144/0000144411.fid, http://foo2:7500/dev1/0/000/144/0000144411.fid
42 part 2 bytes=6 md5=d3b4d15c294b24d9f853e26095dfe3d0 paths: http://foo4:7500/dev2/0/000/144/0000144411.fid, http://foo3:7500/dev1/0/000/144/0000144411.fid
43 EOS
44     i = bigfile_parse_info(s)
45     assert_equal expect, i
46   end
48 end