mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Fix postgresql tests using position in the argument list of psql.
Some tests use position number in the argument list of psql command to check their results. As #36787 add one element, next position in the list must be used.
This commit is contained in:
parent
21f2a17a07
commit
8b92ae2061
@ -237,11 +237,11 @@ class PostgresTestCase(TestCase):
|
|||||||
runas='foo'
|
runas='foo'
|
||||||
)
|
)
|
||||||
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
||||||
# The first 13 elements of this list are initial args used in all (or
|
# The first 14 elements of this list are initial args used in all (or
|
||||||
# virtually all) commands run through _run_psql(), so the actual SQL
|
# virtually all) commands run through _run_psql(), so the actual SQL
|
||||||
# query will be in the 14th argument.
|
# query will be in the 15th argument.
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
postgres._run_psql.call_args[0][0][13].startswith('CREATE ROLE')
|
postgres._run_psql.call_args[0][0][14].startswith('CREATE ROLE')
|
||||||
)
|
)
|
||||||
|
|
||||||
@patch('salt.modules.postgres._run_psql',
|
@patch('salt.modules.postgres._run_psql',
|
||||||
@ -286,13 +286,13 @@ class PostgresTestCase(TestCase):
|
|||||||
runas='foo'
|
runas='foo'
|
||||||
)
|
)
|
||||||
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
||||||
# The first 13 elements of this list are initial args used in all (or
|
# The first 14 elements of this list are initial args used in all (or
|
||||||
# virtually all) commands run through _run_psql(), so the actual SQL
|
# virtually all) commands run through _run_psql(), so the actual SQL
|
||||||
# query will be in the 14th argument.
|
# query will be in the 15th argument.
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
re.match(
|
re.match(
|
||||||
'ALTER.* "testgroup" .* UNENCRYPTED PASSWORD',
|
'ALTER.* "testgroup" .* UNENCRYPTED PASSWORD',
|
||||||
postgres._run_psql.call_args[0][0][13]
|
postgres._run_psql.call_args[0][0][14]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -320,10 +320,10 @@ class PostgresTestCase(TestCase):
|
|||||||
runas='foo'
|
runas='foo'
|
||||||
)
|
)
|
||||||
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
||||||
# The first 13 elements of this list are initial args used in all (or
|
# The first 14 elements of this list are initial args used in all (or
|
||||||
# virtually all) commands run through _run_psql(), so the actual SQL
|
# virtually all) commands run through _run_psql(), so the actual SQL
|
||||||
# query will be in the 14th argument.
|
# query will be in the 15th argument.
|
||||||
call = postgres._run_psql.call_args[0][0][13]
|
call = postgres._run_psql.call_args[0][0][14]
|
||||||
self.assertTrue(re.match('CREATE ROLE "testuser"', call))
|
self.assertTrue(re.match('CREATE ROLE "testuser"', call))
|
||||||
for i in (
|
for i in (
|
||||||
'INHERIT NOCREATEDB NOCREATEROLE '
|
'INHERIT NOCREATEDB NOCREATEROLE '
|
||||||
@ -449,16 +449,16 @@ class PostgresTestCase(TestCase):
|
|||||||
runas='foo'
|
runas='foo'
|
||||||
)
|
)
|
||||||
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
||||||
# The first 13 elements of this list are initial args used in all (or
|
# The first 14 elements of this list are initial args used in all (or
|
||||||
# virtually all) commands run through _run_psql(), so the actual SQL
|
# virtually all) commands run through _run_psql(), so the actual SQL
|
||||||
# query will be in the 14th argument.
|
# query will be in the 15th argument.
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
re.match(
|
re.match(
|
||||||
'ALTER ROLE "test_username" WITH INHERIT NOCREATEDB '
|
'ALTER ROLE "test_username" WITH INHERIT NOCREATEDB '
|
||||||
'NOCREATEROLE NOREPLICATION LOGIN '
|
'NOCREATEROLE NOREPLICATION LOGIN '
|
||||||
'UNENCRYPTED PASSWORD [\'"]{0,5}test_role_pass[\'"]{0,5};'
|
'UNENCRYPTED PASSWORD [\'"]{0,5}test_role_pass[\'"]{0,5};'
|
||||||
' GRANT "test_groups" TO "test_username"',
|
' GRANT "test_groups" TO "test_username"',
|
||||||
postgres._run_psql.call_args[0][0][13]
|
postgres._run_psql.call_args[0][0][14]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -521,15 +521,15 @@ class PostgresTestCase(TestCase):
|
|||||||
runas='foo'
|
runas='foo'
|
||||||
)
|
)
|
||||||
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
||||||
# The first 13 elements of this list are initial args used in all (or
|
# The first 14 elements of this list are initial args used in all (or
|
||||||
# virtually all) commands run through _run_psql(), so the actual SQL
|
# virtually all) commands run through _run_psql(), so the actual SQL
|
||||||
# query will be in the 14th argument.
|
# query will be in the 15th argument.
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
re.match(
|
re.match(
|
||||||
'ALTER ROLE "test_username" WITH INHERIT NOCREATEDB '
|
'ALTER ROLE "test_username" WITH INHERIT NOCREATEDB '
|
||||||
'CREATEROLE NOREPLICATION LOGIN NOPASSWORD;'
|
'CREATEROLE NOREPLICATION LOGIN NOPASSWORD;'
|
||||||
' GRANT "test_groups" TO "test_username"',
|
' GRANT "test_groups" TO "test_username"',
|
||||||
postgres._run_psql.call_args[0][0][13]
|
postgres._run_psql.call_args[0][0][14]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -557,9 +557,9 @@ class PostgresTestCase(TestCase):
|
|||||||
runas='foo'
|
runas='foo'
|
||||||
)
|
)
|
||||||
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
||||||
# The first 13 elements of this list are initial args used in all (or
|
# The first 14 elements of this list are initial args used in all (or
|
||||||
# virtually all) commands run through _run_psql(), so the actual SQL
|
# virtually all) commands run through _run_psql(), so the actual SQL
|
||||||
# query will be in the 14th argument.
|
# query will be in the 15th argument.
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
re.match(
|
re.match(
|
||||||
'ALTER ROLE "test_username" WITH INHERIT NOCREATEDB '
|
'ALTER ROLE "test_username" WITH INHERIT NOCREATEDB '
|
||||||
@ -567,7 +567,7 @@ class PostgresTestCase(TestCase):
|
|||||||
'ENCRYPTED PASSWORD '
|
'ENCRYPTED PASSWORD '
|
||||||
'[\'"]{0,5}md531c27e68d3771c392b52102c01be1da1[\'"]{0,5}'
|
'[\'"]{0,5}md531c27e68d3771c392b52102c01be1da1[\'"]{0,5}'
|
||||||
'; GRANT "test_groups" TO "test_username"',
|
'; GRANT "test_groups" TO "test_username"',
|
||||||
postgres._run_psql.call_args[0][0][13]
|
postgres._run_psql.call_args[0][0][14]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -583,13 +583,13 @@ class PostgresTestCase(TestCase):
|
|||||||
runas='foo'
|
runas='foo'
|
||||||
)
|
)
|
||||||
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
# postgres._run_psql.call_args[0][0] will contain the list of CLI args.
|
||||||
# The first 13 elements of this list are initial args used in all (or
|
# The first 14 elements of this list are initial args used in all (or
|
||||||
# virtually all) commands run through _run_psql(), so the actual SQL
|
# virtually all) commands run through _run_psql(), so the actual SQL
|
||||||
# query will be in the 14th argument.
|
# query will be in the 15th argument.
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
re.match(
|
re.match(
|
||||||
'SELECT setting FROM pg_catalog.pg_settings',
|
'SELECT setting FROM pg_catalog.pg_settings',
|
||||||
postgres._run_psql.call_args[0][0][13]
|
postgres._run_psql.call_args[0][0][14]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user