spec/source_sync_spec.rb in rhosync-2.1.0.beta.1 vs spec/source_sync_spec.rb in rhosync-2.1.0.beta.2
- old
+ new
@@ -70,10 +70,21 @@
@s.docname(:metadata) => "{\"foo\":\"bar\"}",
@s.docname(:metadata_sha1) => "a5e744d0164540d33b1d7ea616c28f2fa97e754a")
end
end
+ it "should process source adapter schema" do
+ mock_schema_method([SampleAdapter]) do
+ expected = {'1'=>@product1,'2'=>@product2}
+ set_state('test_db_storage' => expected)
+ @ss.process_query
+ verify_result(@s.docname(:md) => expected,
+ @s.docname(:schema) => "{\"property\":{\"brand\":\"string\",\"name\":\"string\"},\"version\":\"1.0\"}",
+ @s.docname(:schema_sha1) => "8c148c8c1a66c7baf685c07d58bea360da87981b")
+ end
+ end
+
it "should process source adapter with stash" do
expected = {'1'=>@product1,'2'=>@product2}
set_state('test_db_storage' => expected)
#@ss.adapter.should_receive(:stash_result).once
@ss.process_query('stash_result' => true)
@@ -92,10 +103,20 @@
@ss.adapter.should_receive(:logoff).once.with(no_args()).and_return(nil)
@ss.process_query
end
end
+ it "should process source adapter with pass_through set" do
+ expected = {'1'=>@product1,'2'=>@product2}
+ set_state('test_db_storage' => expected)
+ @s.pass_through = 'true'
+ @ss.process_query.should == expected
+ verify_result(@s.docname(:md) => {},
+ @s.docname(:md_size) => nil)
+ @s.pass_through = nil
+ end
+
describe "create" do
it "should do create where adapter.create returns nil" do
set_state(@c.docname(:create) => {'2'=>@product2})
@ss.create(@c.id)
verify_result(@c.docname(:create_errors) => {},
@@ -217,25 +238,25 @@
if operation == 'query'
@ss.read.should == true
verify_result(@s.docname(:md) => expected,
@s.docname(:errors) => {})
else
- @ss.search(@c.id).should == true
+ @ss.search(@c.id).should == expected
verify_result(@c.docname(:search) => expected,
@c.docname(:search_errors) => {})
end
end
def verify_read_operation_with_error(operation)
msg = "Error during #{operation}"
@ss.should_receive(:log).with("SourceAdapter raised #{operation} exception: #{msg}")
set_test_data('test_db_storage',{},msg,"#{operation} error")
if operation == 'query'
- @ss.read.should == true
+ @ss.read.should be_nil
verify_result(@s.docname(:md) => {},
@s.docname(:errors) => {'query-error'=>{'message'=>msg}})
else
- @ss.search(@c.id).should == true
+ @ss.search(@c.id).should be_nil
verify_result(@c.docname(:search) => {},
@c.docname(:search_errors) => {'search-error'=>{'message'=>msg}})
end
end
end
\ No newline at end of file