spec/flydata/command/sync_spec.rb in flydata-0.2.15 vs spec/flydata/command/sync_spec.rb in flydata-0.2.16

- old
+ new

@@ -54,11 +54,11 @@ end end context 'with full options' do it 'issues mysqldump command with expected parameters' do expect(Open3).to receive(:popen3).with( - 'mysqldump --protocol=tcp -d -h localhost -P 3306 -u masashi -pwelcome sync_test table1 table2') + 'MYSQL_PWD="welcome" mysqldump --protocol=tcp -d -h localhost -P 3306 -u masashi sync_test table1 table2') subject.send(:do_generate_table_ddl, default_data_entry) end end context 'without_host' do before do @@ -76,21 +76,21 @@ before do default_data_entry['mysql_data_entry_preference'].delete('port') end it "uses the default port" do expect(Open3).to receive(:popen3).with( - 'mysqldump --protocol=tcp -d -h localhost -P 3306 -u masashi -pwelcome sync_test table1 table2') + 'MYSQL_PWD="welcome" mysqldump --protocol=tcp -d -h localhost -P 3306 -u masashi sync_test table1 table2') subject.send(:do_generate_table_ddl, default_data_entry) end end context 'with_port_override' do before do default_data_entry['mysql_data_entry_preference']['port'] = 1234 end it "uses the specified port" do expect(Open3).to receive(:popen3).with( - 'mysqldump --protocol=tcp -d -h localhost -P 1234 -u masashi -pwelcome sync_test table1 table2') + 'MYSQL_PWD="welcome" mysqldump --protocol=tcp -d -h localhost -P 1234 -u masashi sync_test table1 table2') subject.send(:do_generate_table_ddl, default_data_entry) end end context 'without_username' do before do @@ -106,12 +106,23 @@ end context 'without_password' do before do default_data_entry['mysql_data_entry_preference'].delete('password') end - it "call mysqldump without -p option" do + it "call mysqldump without MYSQL_PW set" do expect(Open3).to receive(:popen3).with( - 'mysqldump --protocol=tcp -d -h localhost -P 3306 -u masashi sync_test table1 table2') + 'MYSQL_PWD="" mysqldump --protocol=tcp -d -h localhost -P 3306 -u masashi sync_test table1 table2') + subject.send(:do_generate_table_ddl, default_data_entry) + end + end + context 'with password containing symbols' do + before do + default_data_entry['mysql_data_entry_preference'].delete('password') + default_data_entry['mysql_data_entry_preference']['password']="welcome&!@^@#^" + end + it "call mysqldump with MYSQL_PW set with correct symbols" do + expect(Open3).to receive(:popen3).with( + 'MYSQL_PWD="welcome&!@^@#^" mysqldump --protocol=tcp -d -h localhost -P 3306 -u masashi sync_test table1 table2') subject.send(:do_generate_table_ddl, default_data_entry) end end context 'without_database' do before do