Skip to content

Commit

Permalink
CAT-1147 mysql erb to epp rubocop fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinesh Gujar authored and Dinesh Gujar committed Aug 2, 2023
1 parent 8fe879e commit eadd13a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lib/puppet/functions/mysql/innobackupex_args.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

def innobackupex_args(backupuser, backupcompress, backuppassword_unsensitive, backupdatabases, optional_args)
innobackupex_args = ''
innobackupex_args = "--user=\"#{backupuser}\" --password=\"#{backuppassword_unsensitive}\"" if backupuser and backuppassword_unsensitive
innobackupex_args = "--user=\"#{backupuser}\" --password=\"#{backuppassword_unsensitive}\"" if backupuser && backuppassword_unsensitive

innobackupex_args = "#{innobackupex_args} --compress" if backupcompress

innobackupex_args = "#{innobackupex_args} --databases=\"#{backupdatabases.join(' ')}\"" if backupdatabases.is_a?(Array) and !backupdatabases.empty?
innobackupex_args = "#{innobackupex_args} --databases=\"#{backupdatabases.join(' ')}\"" if backupdatabases.is_a?(Array) && !backupdatabases.empty?

if optional_args.is_a?(Array)
optional_args.each do |arg|
Expand Down
36 changes: 15 additions & 21 deletions spec/functions/mysql_innobackupex_args_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,48 @@
expect(subject).not_to be_nil

Check failure on line 7 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)

Check failure on line 7 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)
end

# it 'throws error with no arguments' do
# expect(subject).to run.with_params().and_raise_error(Puppet::ArgumentError)
# end

it 'accepts empty strings as puppet undef' do
expect(subject).to run.with_params('', true, '', [], [])

Check failure on line 11 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)

Check failure on line 11 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)
end

it 'returns args with username and password' do

Check failure on line 14 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

RSpec/RepeatedExample: Don't repeat examples within an example group. (https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedExample)

Check failure on line 14 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

RSpec/RepeatedExample: Don't repeat examples within an example group. (https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedExample)
expect(subject).to run.with_params('root', false, '12345', [], []).and_return("--user=\"root\" --password=\"12345\"")
expect(subject).to run.with_params('root', false, '12345', [], []).and_return('--user="root" --password="12345"')

Check failure on line 15 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)

Check failure on line 15 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)
end

it 'returns args with database lists' do
expect(subject).to run.with_params('root', false, '12345', ['db1','db2'], []).and_return("--user=\"root\" --password=\"12345\" --databases=\"db1 db2\"")
expect(subject).to run.with_params('root', false, '12345', ['db1', 'db2'], []).and_return('--user="root" --password="12345" --databases="db1 db2"')

Check failure on line 19 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)

Check failure on line 19 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)
end

it 'returns args without database list' do

Check failure on line 22 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

RSpec/RepeatedExample: Don't repeat examples within an example group. (https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedExample)

Check failure on line 22 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

RSpec/RepeatedExample: Don't repeat examples within an example group. (https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedExample)
expect(subject).to run.with_params('root', false, '12345', [], []).and_return("--user=\"root\" --password=\"12345\"")
expect(subject).to run.with_params('root', false, '12345', [], []).and_return('--user="root" --password="12345"')

Check failure on line 23 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)

Check failure on line 23 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)
end

it 'returns args without backup compress' do

Check failure on line 26 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

RSpec/RepeatedExample: Don't repeat examples within an example group. (https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedExample)

Check failure on line 26 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

RSpec/RepeatedExample: Don't repeat examples within an example group. (https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedExample)
expect(subject).to run.with_params('root', false, '12345', [], []).and_return("--user=\"root\" --password=\"12345\"")
expect(subject).to run.with_params('root', false, '12345', [], []).and_return('--user="root" --password="12345"')

Check failure on line 27 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)

Check failure on line 27 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)
end

it 'returns args with backup compress only' do
expected_results = "--user=\"root\" --password=\"12345\" --compress"
expected_results = '--user="root" --password="12345" --compress'
expect(subject).to run.with_params('root', true, '12345', [], []).and_return(expected_results)

Check failure on line 32 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)

Check failure on line 32 in spec/functions/mysql_innobackupex_args_spec.rb

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

RSpec/NamedSubject: Name your test subject if you need to reference it explicitly. (https://rspec.rubystyle.guide/#use-subject, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject)
end

it 'returns args with backup compress and database list' do
expected_results = "--user=\"root\" --password=\"12345\" --compress --databases=\"db1 db2\""
expect(subject).to run.with_params('root', true, '12345', ['db1','db2'], []).and_return(expected_results)
expected_results = '--user="root" --password="12345" --compress --databases="db1 db2"'
expect(subject).to run.with_params('root', true, '12345', ['db1', 'db2'], []).and_return(expected_results)
end

it 'returns args with backup compress, database list and optional_args' do
expected_results = "--user=\"root\" --password=\"12345\" --compress --databases=\"db1 db2\" tst_arg_1 tst_arg_2"
expect(subject).to run.with_params('root', true, '12345', ['db1','db2'], ["tst_arg_1", "tst_arg_2"]).and_return(expected_results)
expected_results = '--user="root" --password="12345" --compress --databases="db1 db2" tst_arg_1 tst_arg_2'
expect(subject).to run.with_params('root', true, '12345', ['db1', 'db2'], ['tst_arg_1', 'tst_arg_2']).and_return(expected_results)
end

it 'returns args without backup compress, database list and optional_args' do
expected_results = "--user=\"root\" --password=\"12345\" --databases=\"db1 db2\" tst_arg_1 tst_arg_2"
expect(subject).to run.with_params('root', false, '12345', ['db1','db2'], ["tst_arg_1", "tst_arg_2"]).and_return(expected_results)
it 'returns args without backup compress database list and optional_args' do
expected_results = '--user="root" --password="12345" --databases="db1 db2" tst_arg_1 tst_arg_2'
expect(subject).to run.with_params('root', false, '12345', ['db1', 'db2'], ['tst_arg_1', 'tst_arg_2']).and_return(expected_results)
end

it 'returns args without backup compress, database list and with optional_args' do
expected_results = "--user=\"root\" --password=\"12345\" tst_arg_1 tst_arg_2"
expect(subject).to run.with_params('root', false, '12345', [], ["tst_arg_1", "tst_arg_2"]).and_return(expected_results)
it 'returns args without backup compress database list and with optional_args' do
expected_results = '--user="root" --password="12345" tst_arg_1 tst_arg_2'
expect(subject).to run.with_params('root', false, '12345', [], ['tst_arg_1', 'tst_arg_2']).and_return(expected_results)
end


end

0 comments on commit eadd13a

Please sign in to comment.