test/unit/ut_17_storage.rb in ruote-2.1.3 vs test/unit/ut_17_storage.rb in ruote-2.1.4
- old
+ new
@@ -8,21 +8,25 @@
begin
require 'yajl'
rescue LoadError
require 'json'
end
-require 'patron' rescue nil
+begin
+ require 'patron'
+rescue LoadError
+ # stick with net/http
+end
require File.join(File.dirname(__FILE__), %w[ .. test_helper.rb ])
require File.join(File.dirname(__FILE__), %w[ .. functional storage_helper.rb ])
class UtStorage < Test::Unit::TestCase
def setup
@s = determine_storage({})
- @s.add_test_type('dogfood') if @s.respond_to?(:add_test_type)
+ @s.add_type('dogfood')
@s.put(
'_id' => 'toto',
'type' => 'dogfood',
'message' => 'testing')
end
@@ -127,8 +131,24 @@
assert_nil @s.delete(h)
h['colour'] = 'blue'
assert_equal true, @s.put(h)
+ end
+
+ def test_purge_type
+
+ @s.purge_type!('dogfood')
+
+ assert_equal 0, @s.get_many('dogfood').size
+ end
+
+ def test_ids
+
+ @s.put('_id' => 'ouinouin', 'type' => 'dogfood', 'message' => 'testing')
+ @s.put('_id' => 'nada', 'type' => 'dogfood', 'message' => 'testing')
+ @s.put('_id' => 'estereo', 'type' => 'dogfood', 'message' => 'testing')
+
+ assert_equal %w[ estereo nada ouinouin toto ], @s.ids('dogfood')
end
end