Skip to content

Commit 46007d8

Browse files
committed
(GH-cat-9) Rubocop fixes
1 parent 9ef417c commit 46007d8

File tree

2 files changed

+41
-45
lines changed

2 files changed

+41
-45
lines changed

spec/acceptance/db_spec.rb

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,43 @@
44

55
describe 'postgresql::server::db' do
66
it 'creates a database' do
7-
begin
8-
tmpdir = run_shell('mktemp').stdout
9-
pp = <<-MANIFEST
10-
class { 'postgresql::server':
11-
postgres_password => 'space password',
12-
}
13-
postgresql::server::tablespace { 'postgresql-test-db':
14-
location => '#{tmpdir}',
15-
} ->
16-
postgresql::server::db { 'postgresql-test-db':
17-
comment => 'testcomment',
18-
user => 'test-user',
19-
password => 'test1',
20-
tablespace => 'postgresql-test-db',
21-
}
22-
MANIFEST
7+
tmpdir = run_shell('mktemp').stdout
8+
pp = <<-MANIFEST
9+
class { 'postgresql::server':
10+
postgres_password => 'space password',
11+
}
12+
postgresql::server::tablespace { 'postgresql-test-db':
13+
location => '#{tmpdir}',
14+
} ->
15+
postgresql::server::db { 'postgresql-test-db':
16+
comment => 'testcomment',
17+
user => 'test-user',
18+
password => 'test1',
19+
tablespace => 'postgresql-test-db',
20+
}
21+
MANIFEST
2322

24-
idempotent_apply(pp)
23+
idempotent_apply(pp)
2524

26-
# Verify that the postgres password works
27-
run_shell("echo 'localhost:*:*:postgres:\'space password\'' > /root/.pgpass")
28-
run_shell('chmod 600 /root/.pgpass')
29-
run_shell("psql -U postgres -h localhost --command='\\l'")
25+
# Verify that the postgres password works
26+
run_shell("echo 'localhost:*:*:postgres:\'space password\'' > /root/.pgpass")
27+
run_shell('chmod 600 /root/.pgpass')
28+
run_shell("psql -U postgres -h localhost --command='\\l'")
3029

31-
result = psql('--command="select datname from pg_database" "postgresql-test-db"')
32-
expect(result.stdout).to match(%r{postgresql-test-db})
33-
expect(result.stderr).to eq('')
30+
result = psql('--command="select datname from pg_database" "postgresql-test-db"')
31+
expect(result.stdout).to match(%r{postgresql-test-db})
32+
expect(result.stderr).to eq('')
3433

35-
result = psql('--command="SELECT 1 FROM pg_roles WHERE rolname=\'test-user\'"')
36-
expect(result.stdout).to match(%r{\(1 row\)})
37-
comment_information_function = if Gem::Version.new(postgresql_version) > Gem::Version.new('8.1')
38-
'shobj_description'
39-
else
40-
'obj_description'
41-
end
42-
result = psql("--dbname postgresql-test-db --command=\"SELECT pg_catalog.#{comment_information_function}(d.oid, 'pg_database') FROM pg_catalog.pg_database d WHERE datname = 'postgresql-test-db' AND pg_catalog.#{comment_information_function}(d.oid, 'pg_database') = 'testcomment'\"") # rubocop:disable Layout/LineLength
43-
expect(result.stdout).to match(%r{\(1 row\)})
44-
ensure
45-
psql('--command=\'drop database "postgresql-test-db"\'')
46-
end
34+
result = psql('--command="SELECT 1 FROM pg_roles WHERE rolname=\'test-user\'"')
35+
expect(result.stdout).to match(%r{\(1 row\)})
36+
comment_information_function = if Gem::Version.new(postgresql_version) > Gem::Version.new('8.1')
37+
'shobj_description'
38+
else
39+
'obj_description'
40+
end
41+
result = psql("--dbname postgresql-test-db --command=\"SELECT pg_catalog.#{comment_information_function}(d.oid, 'pg_database') FROM pg_catalog.pg_database d WHERE datname = 'postgresql-test-db' AND pg_catalog.#{comment_information_function}(d.oid, 'pg_database') = 'testcomment'\"") # rubocop:disable Layout/LineLength
42+
expect(result.stdout).to match(%r{\(1 row\)})
43+
ensure
44+
psql('--command=\'drop database "postgresql-test-db"\'')
4745
end
4846
end

spec/acceptance/server/schema_spec.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,14 @@ class { 'postgresql::server': }
5656
end
5757

5858
it 'creates a schema for a user' do
59-
begin
60-
idempotent_apply(pp)
59+
idempotent_apply(pp)
6160

62-
## Check that the user can create a table in the database
63-
psql('--command="create table psql_schema_tester.foo (foo int)" schema_test', 'psql_schema_tester') do |r|
64-
expect(r.stdout).to match(%r{CREATE TABLE})
65-
expect(r.stderr).to eq('')
66-
end
67-
ensure
68-
psql('--command="drop table psql_schema_tester.foo" schema_test', 'psql_schema_tester')
61+
## Check that the user can create a table in the database
62+
psql('--command="create table psql_schema_tester.foo (foo int)" schema_test', 'psql_schema_tester') do |r|
63+
expect(r.stdout).to match(%r{CREATE TABLE})
64+
expect(r.stderr).to eq('')
6965
end
66+
ensure
67+
psql('--command="drop table psql_schema_tester.foo" schema_test', 'psql_schema_tester')
7068
end
7169
end

0 commit comments

Comments
 (0)