Skip to content

Commit

Permalink
(maint) fix all spec rubocops
Browse files Browse the repository at this point in the history
  • Loading branch information
h0tw1r3 committed May 4, 2024
1 parent 33211ed commit 3aae838
Show file tree
Hide file tree
Showing 15 changed files with 174 additions and 209 deletions.
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ AllCops:
- "**/Puppetfile"
- "**/Vagrantfile"
- "**/Guardfile"
inherit_from: ".rubocop_todo.yml"
Layout/LineLength:
Description: People have wide screens, use them.
Max: 200
Expand Down
25 changes: 0 additions & 25 deletions .rubocop_todo.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .sync.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
---
.rubocop.yml:
include_todos: true


spec/spec_helper.rb:
spec_overrides:
- require 'spec_helper_local'
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/graceful_failures_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
end

it 'gracefully fails' do
expect(subject).to compile.and_raise_error(%r{Unsupported platform:})
is_expected.to compile.and_raise_error(%r{Unsupported platform:})
end
end
end
26 changes: 13 additions & 13 deletions spec/classes/mycnf_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
let(:params) { { override_options: { 'mysqld' => { 'socket' => '/var/lib/mysql/mysql.sock' } } } }

it do
expect(subject).to contain_file('mysql-config-file').with(mode: '0644',
is_expected.to contain_file('mysql-config-file').with(mode: '0644',
selinux_ignore_defaults: true).with_content(%r{socket = /var/lib/mysql/mysql.sock})
end
end
Expand All @@ -22,7 +22,7 @@
let(:params) { { override_options: { 'mysqld' => { 'replicate-do-db' => ['base1', 'base2'] } } } }

it do
expect(subject).to contain_file('mysql-config-file').with_content(
is_expected.to contain_file('mysql-config-file').with_content(
%r{.*replicate-do-db = base1\nreplicate-do-db = base2.*},
)
end
Expand Down Expand Up @@ -80,7 +80,7 @@
let(:params) { { includedir: '/etc/my.cnf.d' } }

it 'makes the directory' do
expect(subject).to contain_file('/etc/my.cnf.d').with(ensure: :directory,
is_expected.to contain_file('/etc/my.cnf.d').with(ensure: :directory,
mode: '0755')
end

Expand All @@ -91,7 +91,7 @@
let(:params) { { includedir: '' } }

it 'shouldnt contain the directory' do
expect(subject).not_to contain_file('mysql-config-file').with(ensure: :directory,
is_expected.not_to contain_file('mysql-config-file').with(ensure: :directory,
mode: '0755')
end

Expand All @@ -102,55 +102,55 @@
let(:params) { { 'config_file_mode' => '0644' } }

it do
expect(subject).to contain_file('mysql-config-file').with(mode: '0644')
is_expected.to contain_file('mysql-config-file').with(mode: '0644')
end
end

context 'with file mode 0664' do
let(:params) { { 'config_file_mode' => '0664' } }

it do
expect(subject).to contain_file('mysql-config-file').with(mode: '0664')
is_expected.to contain_file('mysql-config-file').with(mode: '0664')
end
end

context 'with file mode 0660' do
let(:params) { { 'config_file_mode' => '0660' } }

it do
expect(subject).to contain_file('mysql-config-file').with(mode: '0660')
is_expected.to contain_file('mysql-config-file').with(mode: '0660')
end
end

context 'with file mode 0641' do
let(:params) { { 'config_file_mode' => '0641' } }

it do
expect(subject).to contain_file('mysql-config-file').with(mode: '0641')
is_expected.to contain_file('mysql-config-file').with(mode: '0641')
end
end

context 'with file mode 0610' do
let(:params) { { 'config_file_mode' => '0610' } }

it do
expect(subject).to contain_file('mysql-config-file').with(mode: '0610')
is_expected.to contain_file('mysql-config-file').with(mode: '0610')
end
end

context 'with file 0600' do
let(:params) { { 'config_file_mode' => '0600' } }

it do
expect(subject).to contain_file('mysql-config-file').with(mode: '0600')
is_expected.to contain_file('mysql-config-file').with(mode: '0600')
end
end

context 'user owner 12345' do
let(:params) { { 'mycnf_owner' => '12345' } }

it do
expect(subject).to contain_file('mysql-config-file').with(
is_expected.to contain_file('mysql-config-file').with(
owner: '12345',
)
end
Expand All @@ -160,7 +160,7 @@
let(:params) { { 'mycnf_group' => '12345' } }

it do
expect(subject).to contain_file('mysql-config-file').with(
is_expected.to contain_file('mysql-config-file').with(
group: '12345',
)
end
Expand All @@ -170,7 +170,7 @@
let(:params) { { 'mycnf_owner' => '12345', 'mycnf_group' => '12345' } }

it do
expect(subject).to contain_file('mysql-config-file').with(
is_expected.to contain_file('mysql-config-file').with(
owner: '12345',
group: '12345',
)
Expand Down
12 changes: 6 additions & 6 deletions spec/classes/mysql_backup_mysqldump_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class { 'mysql::server': }
end

it {
expect(subject).to contain_cron('mysql-backup').with(
is_expected.to contain_cron('mysql-backup').with(
hour: 23,
minute: 59,
monthday: 30,
Expand All @@ -46,7 +46,7 @@ class { 'mysql::server': }
it { is_expected.to contain_class('mysql::params') }

it {
expect(subject).to contain_cron('mysql-backup').with(
is_expected.to contain_cron('mysql-backup').with(
command: '/usr/local/sbin/mysqlbackup.sh',
ensure: 'present',
hour: 23,
Expand All @@ -64,13 +64,13 @@ class { 'mysql::server': }
end

it {
expect(subject).to contain_file('mysqlbackup.sh').with_content(
is_expected.to contain_file('mysqlbackup.sh').with_content(
%r{(\| TEST -TEST)},
)
expect(subject).to contain_file('mysqlbackup.sh').with_content(
is_expected.to contain_file('mysqlbackup.sh').with_content(
%r{(\.TEST)},
)
expect(subject).not_to contain_package('bzip2')
is_expected.not_to contain_package('bzip2')
}
end

Expand All @@ -83,7 +83,7 @@ class { 'mysql::server': }
end

it {
expect(subject).to contain_file('mysqlbackup.sh').with_content(
is_expected.to contain_file('mysqlbackup.sh').with_content(
%r{information_schema},
)
}
Expand Down
40 changes: 20 additions & 20 deletions spec/classes/mysql_backup_xtrabackup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class { 'mysql::server': }
it { is_expected.to contain_class('mysql::params') }

it 'does not contain the touch command' do
expect(subject).to contain_file('xtrabackup.sh').without_content(
is_expected.to contain_file('xtrabackup.sh').without_content(
%r{(^\s+touch\s+$)},
)
end

it 'contains the wrapper script' do
expect(subject).to contain_file('xtrabackup.sh').with_content(
is_expected.to contain_file('xtrabackup.sh').with_content(
%r{(\n*^xtrabackup\s+.*\$@)},
)
end
Expand All @@ -61,7 +61,7 @@ class { 'mysql::server': }
end

it 'contains the weekly cronjob' do
expect(subject).to contain_cron('xtrabackup-weekly')
is_expected.to contain_cron('xtrabackup-weekly')
.with(
ensure: 'present',
command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/$(date +\%F)_full --backup',
Expand All @@ -80,7 +80,7 @@ class { 'mysql::server': }
else
'$(date -d "last sunday" +\%F)_full'
end
expect(subject).to contain_cron('xtrabackup-daily')
is_expected.to contain_cron('xtrabackup-daily')
.with(
ensure: 'present',
command: "/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp/#{dateformat} --target-dir=/tmp/$(date +\\%F_\\%H-\\%M-\\%S) --backup",
Expand All @@ -100,14 +100,14 @@ class { 'mysql::server': }
end

it 'contains the defined mysql user' do
expect(subject).to contain_mysql_user('backupuser@localhost')
is_expected.to contain_mysql_user('backupuser@localhost')
.with(
ensure: 'present',
password_hash: '*4110E08DF51E70A4BA1D4E33A84205E38CF3FE58',
)
.that_requires('Class[mysql::server::root_password]')

expect(subject).to contain_mysql_grant('backupuser@localhost/*.*')
is_expected.to contain_mysql_grant('backupuser@localhost/*.*')
.with(
ensure: 'present',
user: 'backupuser@localhost',
Expand All @@ -129,9 +129,9 @@ class { 'mysql::server': }
end

it {
expect(subject).not_to contain_mysql_grant('backupuser@localhost/performance_schema.keyring_component_status')
expect(subject).not_to contain_mysql_grant('backupuser@localhost/performance_schema.log_status')
expect(subject).not_to contain_mysql_grant('backupuser@localhost/*.*')
is_expected.not_to contain_mysql_grant('backupuser@localhost/performance_schema.keyring_component_status')
is_expected.not_to contain_mysql_grant('backupuser@localhost/performance_schema.log_status')
is_expected.not_to contain_mysql_grant('backupuser@localhost/*.*')
.with(
ensure: 'present',
user: 'backupuser@localhost',
Expand All @@ -150,7 +150,7 @@ class { 'mysql::server': }
end

it {
expect(subject).to contain_mysql_grant('backupuser@localhost/*.*')
is_expected.to contain_mysql_grant('backupuser@localhost/*.*')
.with(
ensure: 'present',
user: 'backupuser@localhost',
Expand All @@ -164,7 +164,7 @@ class { 'mysql::server': }
end,
)
.that_requires('Mysql_user[backupuser@localhost]')
expect(subject).to contain_mysql_grant('backupuser@localhost/performance_schema.keyring_component_status')
is_expected.to contain_mysql_grant('backupuser@localhost/performance_schema.keyring_component_status')
.with(
ensure: 'present',
user: 'backupuser@localhost',
Expand All @@ -174,7 +174,7 @@ class { 'mysql::server': }
)
.that_requires('Mysql_user[backupuser@localhost]')

expect(subject).to contain_mysql_grant('backupuser@localhost/performance_schema.log_status')
is_expected.to contain_mysql_grant('backupuser@localhost/performance_schema.log_status')
.with(
ensure: 'present',
user: 'backupuser@localhost',
Expand Down Expand Up @@ -221,7 +221,7 @@ class { 'mysql::server': }
end

it 'contains the weekly cronjob' do
expect(subject).to contain_cron('xtrabackup-weekly')
is_expected.to contain_cron('xtrabackup-weekly')
.with(
ensure: 'present',
command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/$(date +\%F)_full --backup --skip-ssl',
Expand All @@ -234,7 +234,7 @@ class { 'mysql::server': }
end

it 'contains the daily cronjob for weekdays 1-6' do
expect(subject).to contain_cron('xtrabackup-daily')
is_expected.to contain_cron('xtrabackup-daily')
.with(
ensure: 'present',
command: "/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp/#{dateformat} --target-dir=/tmp/$(date +\\%F_\\%H-\\%M-\\%S) --backup --skip-ssl",
Expand All @@ -253,11 +253,11 @@ class { 'mysql::server': }
end

it 'not contains the weekly cronjob' do
expect(subject).not_to contain_cron('xtrabackup-weekly')
is_expected.not_to contain_cron('xtrabackup-weekly')
end

it 'contains the daily cronjob with all weekdays' do
expect(subject).to contain_cron('xtrabackup-daily').with(
is_expected.to contain_cron('xtrabackup-daily').with(
ensure: 'present',
command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/$(date +\%F_\%H-\%M-\%S) --backup',
user: 'root',
Expand All @@ -275,7 +275,7 @@ class { 'mysql::server': }
end

it 'contains the prescript' do
expect(subject).to contain_file('xtrabackup.sh').with_content(
is_expected.to contain_file('xtrabackup.sh').with_content(
%r{.*rsync -a /tmp backup01.local-lan:\n\nrsync -a /tmp backup02.local-lan:.*},
)
end
Expand All @@ -288,7 +288,7 @@ class { 'mysql::server': }
end

it 'contains the prostscript' do
expect(subject).to contain_file('xtrabackup.sh').with_content(
is_expected.to contain_file('xtrabackup.sh').with_content(
%r{.*rsync -a /tmp backup01.local-lan:\n\nrsync -a /tmp backup02.local-lan:.*},
)
end
Expand All @@ -301,7 +301,7 @@ class { 'mysql::server': }
end

it 'contain the mariabackup executor' do
expect(subject).to contain_file('xtrabackup.sh').with_content(
is_expected.to contain_file('xtrabackup.sh').with_content(
%r{(\n*^mariabackup\s+.*\$@)},
)
end
Expand All @@ -313,7 +313,7 @@ class { 'mysql::server': }
end

it 'contain the touch /tmp/backup_success command' do
expect(subject).to contain_file('xtrabackup.sh').with_content(
is_expected.to contain_file('xtrabackup.sh').with_content(
%r{(^\s+touch /tmp/backup_success$)},
)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/mysql_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
end

it do
expect(subject).to contain_package('mysql_client').with(
is_expected.to contain_package('mysql_client').with(
provider: 'dpkg',
source: '/somewhere',
)
Expand Down
Loading

0 comments on commit 3aae838

Please sign in to comment.