Add tests, fix dependencies so "bundle exec rake test" runs.
[arvados.git] / sdk / ruby / test / test_big_request.rb
1 require 'minitest/autorun'
2 require 'arvados'
3 require 'digest/md5'
4
5 class TestBigRequest < Minitest::Test
6   def setup
7     begin
8       Dir.mkdir './tmp'
9     rescue Errno::EEXIST
10     end
11     @@arv = Arvados.new
12   end
13
14   def boring_manifest nblocks
15     x = '.'
16     (0..nblocks).each do |z|
17       x += ' d41d8cd98f00b204e9800998ecf8427e+0'
18     end
19     x += "0:0:foo.txt\n"
20     x
21   end
22
23   def test_create_manifest nblocks=1
24     manifest_text = boring_manifest nblocks
25     uuid = Digest::MD5.hexdigest(manifest_text) + '+' + manifest_text.size.to_s
26     c = @@arv.collection.create(collection: {
27                                   uuid: uuid,
28                                   manifest_text: manifest_text
29                                 })
30     assert_equal uuid, c[:uuid]
31   end
32
33   def test_create_big_manifest
34     # This ensures that manifest_text is passed in the request body:
35     # it's too large to fit in the query string.
36     test_create_manifest 9999
37   end
38 end