Permalink
Browse files

functional tests for gridfs write concern

  • Loading branch information...
1 parent c4a3eef commit 7fb1eb15cd58016e9e3b951a1c225cde08a4dd05 @estolfo estolfo committed Nov 20, 2012
Showing with 39 additions and 0 deletions.
  1. +39 −0 test/functional/write_concern_test.rb
@@ -66,6 +66,45 @@ class WriteConcernTest < Test::Unit::TestCase
assert_equal 3, response['n']
end
end
+
+ context "Write concern in gridfs" do
+ setup do
+ @db = standard_connection.db(MONGO_TEST_DB)
+ @grid = Mongo::GridFileSystem.new(@db)
+ @filename = 'sample'
+ end
+
+ teardown do
+ @grid.delete(@filename)
+ end
+
+ should "should acknowledge writes by default using md5" do
+
+ file = @grid.open(@filename, 'w')
+ file.write "Hello world!"
+ file.close
+ assert_equal file.client_md5, file.server_md5
+
+ end
+
+ should "should allow for unacknowledged writes" do
+ file = @grid.open(@filename, 'w', {:w => 0} )
+ file.write "Hello world!"
+ file.close
+ assert_nil file.client_md5, file.server_md5
+
+ end
+
+ should "should support legacy write concern api" do
+
+ file = @grid.open(@filename, 'w', {:safe => false} )
+ file.write "Hello world!"
+ file.close
+ assert_nil file.client_md5, file.server_md5
+
+ end
+
+ end
end

0 comments on commit 7fb1eb1

Please sign in to comment.