Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tests to apply the new array format
  • Loading branch information
y-trobinso committed Jul 31, 2017
commit b6865c8da7272d4467cc934d49fdac1436906ab9
2 changes: 1 addition & 1 deletion manifests/server/dbgroup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
define postgresql::server::dbgroup(
$db = $postgresql::server::default_database,
$port = undef,
$groupmembers = [],
$groupmembers = '{}',
$groupname = $title,
$dialect = $postgresql::server::dialect,
$connect_settings = undef,
Expand Down
18 changes: 8 additions & 10 deletions spec/unit/defines/server/dbgroup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@
'port' => "5432",
})
end
it 'should have update pg_group for test group with groupmembers as []' do
is_expected.to contain_postgresql_psql("test: UPDATE pg_group SET grolist = ARRAY[] WHERE groname = 'test'").with({
'command' => "UPDATE pg_group SET grolist = ARRAY[] WHERE groname = 'test'",
'environment' => [],
'unless' => "SELECT 1 FROM pg_group WHERE groname = 'test' AND grolist = ARRAY[]",
it 'should have update pg_group for test group with groupmembers as {}' do
is_expected.to contain_postgresql_psql("test: UPDATE pg_group SET grolist = '{}' WHERE groname = 'test'").with({
'command' => "UPDATE pg_group SET grolist = '{}' WHERE groname = 'test'",
'unless' => "SELECT 1 FROM pg_group WHERE groname = 'test' AND grolist = '{}'",
'port' => "5432",
})
end
Expand All @@ -51,7 +50,7 @@

let :params do
{
:groupmembers => ['testuser1', 'testuser2'],
:groupmembers => "{\"testuser1\", \"testuser2\"}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I much preferred the prior API. Is it possible to expose the previous API to the caller (array of names) and then do the escaping / formatting yourself inside postgresql::server::dbgroup?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a set of regexp rules to convert puppet arrays to psql arrays.

}
end

Expand All @@ -65,10 +64,9 @@
})
end
it 'should have update pg_group for test group with provided groupmembers' do
is_expected.to contain_postgresql_psql("test: UPDATE pg_group SET grolist = ARRAY[testuser1, testuser2] WHERE groname = 'test'").with({
'command' => "UPDATE pg_group SET grolist = ARRAY[testuser1, testuser2] WHERE groname = 'test'",
'environment' => [],
'unless' => "SELECT 1 FROM pg_group WHERE groname = 'test' AND grolist = ARRAY[testuser1, testuser2]",
is_expected.to contain_postgresql_psql("test: UPDATE pg_group SET grolist = '{\"testuser1\", \"testuser2\"}' WHERE groname = 'test'").with({
'command' => "UPDATE pg_group SET grolist = '{\"testuser1\", \"testuser2\"}' WHERE groname = 'test'",
'unless' => "SELECT 1 FROM pg_group WHERE groname = 'test' AND grolist = '{\"testuser1\", \"testuser2\"}'",
'port' => "5432",
})
end
Expand Down
1 change: 0 additions & 1 deletion spec/unit/defines/server/role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@
it 'should have an alter statement to set PASSWORD DISABLE' do
is_expected.to contain_postgresql_psql('test: ALTER USER "test" PASSWORD DISABLE').with({
'command' => "ALTER USER \"test\" PASSWORD DISABLE",
'environment' => [],
'port' => "5432",
})
end
Expand Down