mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Updated tests with tablespace alter tests
This commit is contained in:
parent
7714b22f07
commit
3c4aa715ba
1 changed files with 82 additions and 5 deletions
|
@ -1,5 +1,4 @@
|
|||
import datetime
|
||||
import logging
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
@ -9,8 +8,6 @@ import salt.modules.postgres as postgres
|
|||
from salt.exceptions import SaltInvocationError
|
||||
from tests.support.mock import MagicMock, Mock, call, patch
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# 'md5' + md5('password' + 'username')
|
||||
md5_pw = "md55a231fcdb710d73268c4f44283487ba2"
|
||||
|
||||
|
@ -2322,8 +2319,6 @@ def test_tablespace_list():
|
|||
runas="foo",
|
||||
)
|
||||
|
||||
log.warning(f"DGM test_tablespace_list ret '{ret}'")
|
||||
|
||||
expected_data = {
|
||||
"pg_global": {"Owner": "postgres", "ACL": "", "Opts": "", "Location": ""},
|
||||
"pg_default": {"Owner": "postgres", "ACL": "", "Opts": "", "Location": ""},
|
||||
|
@ -2433,6 +2428,88 @@ def test_tablespace_exists_false():
|
|||
assert not ret
|
||||
|
||||
|
||||
def test_tablespace_alter_new_owner():
|
||||
with patch(
|
||||
"salt.modules.postgres._run_psql", Mock(return_value={"retcode": 0})
|
||||
), patch("salt.utils.path.which", MagicMock(return_value="/usr/bin/pgsql")):
|
||||
postgres.tablespace_alter(
|
||||
"test_tablespace",
|
||||
user="testuser",
|
||||
host="testhost",
|
||||
port="testport",
|
||||
maintenance_db="maint_db",
|
||||
password="foo",
|
||||
runas="foo",
|
||||
new_owner="testuser",
|
||||
)
|
||||
|
||||
postgres._run_psql.assert_called_once_with(
|
||||
[
|
||||
"/usr/bin/pgsql",
|
||||
"--no-align",
|
||||
"--no-readline",
|
||||
"--no-psqlrc",
|
||||
"--no-password",
|
||||
"--username",
|
||||
"testuser",
|
||||
"--host",
|
||||
"testhost",
|
||||
"--port",
|
||||
"testport",
|
||||
"--dbname",
|
||||
"maint_db",
|
||||
"-c",
|
||||
'ALTER TABLESPACE "test_tablespace" OWNER TO "testuser"',
|
||||
],
|
||||
runas="foo",
|
||||
password="foo",
|
||||
host="testhost",
|
||||
port="testport",
|
||||
user="testuser",
|
||||
)
|
||||
|
||||
|
||||
def test_tablespace_alter_new_name():
|
||||
with patch(
|
||||
"salt.modules.postgres._run_psql", Mock(return_value={"retcode": 0})
|
||||
), patch("salt.utils.path.which", MagicMock(return_value="/usr/bin/pgsql")):
|
||||
postgres.tablespace_alter(
|
||||
"test_tablespace",
|
||||
user="testuser",
|
||||
host="testhost",
|
||||
port="testport",
|
||||
maintenance_db="maint_db",
|
||||
password="foo",
|
||||
runas="foo",
|
||||
new_name="test_tablespace2",
|
||||
)
|
||||
|
||||
postgres._run_psql.assert_called_once_with(
|
||||
[
|
||||
"/usr/bin/pgsql",
|
||||
"--no-align",
|
||||
"--no-readline",
|
||||
"--no-psqlrc",
|
||||
"--no-password",
|
||||
"--username",
|
||||
"testuser",
|
||||
"--host",
|
||||
"testhost",
|
||||
"--port",
|
||||
"testport",
|
||||
"--dbname",
|
||||
"maint_db",
|
||||
"-c",
|
||||
'ALTER TABLESPACE "test_tablespace" RENAME TO "test_tablespace2"',
|
||||
],
|
||||
runas="foo",
|
||||
password="foo",
|
||||
host="testhost",
|
||||
port="testport",
|
||||
user="testuser",
|
||||
)
|
||||
|
||||
|
||||
def test_tablespace_remove():
|
||||
with patch(
|
||||
"salt.modules.postgres._run_psql", Mock(return_value={"retcode": 0})
|
||||
|
|
Loading…
Add table
Reference in a new issue