spec/flydata/command/sync_spec.rb in flydata-0.2.18 vs spec/flydata/command/sync_spec.rb in flydata-0.2.19
- old
+ new
@@ -42,11 +42,30 @@
if File.exists?(default_mysqldump_dir)
File.delete(default_mysqldump_dir) rescue nil
end
end
+ subject { Sync.new }
+ describe '#cleanup_sync_server' do
+ let(:rest_client) { double('rest_client') }
+
+ context "when rest client throws timeout errors" do
+ before do
+ allow(RestClient::Resource).to receive(:new).and_return(rest_client)
+ end
+ it "should retry in case of RestClient::RequestTimeout" do
+ expect(rest_client).to receive(:post).and_raise(RestClient::RequestTimeout)
+ expect(rest_client).to receive(:post).and_return("{}")
+ subject.send(:cleanup_sync_server, default_data_entry)
+ end
+ it "should retry in case of RestClient::GatewayTimeout" do
+ expect(rest_client).to receive(:post).and_raise(RestClient::GatewayTimeout)
+ expect(rest_client).to receive(:post).and_return("{}")
+ subject.send(:cleanup_sync_server, default_data_entry)
+ end
+ end
+ end
describe '#do_generate_table_ddl' do
- subject { Sync.new }
shared_examples 'throws an error' do
it "throws an error" do
expect {
subject.send(:do_generate_table_ddl, default_data_entry)
}.to raise_error