mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Call initdb directly (#2633)
Previously it was called via `pg_ctl`, what required a special quoting of parameters passed to `initdb`. Co-authored-by: Israel <[email protected]>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from mock import Mock, PropertyMock, patch
|
||||
|
||||
@@ -99,6 +100,48 @@ class TestBootstrap(BaseTestPostgresql):
|
||||
self.assertRaises(Exception, self.b.bootstrap, {'initdb': [1]})
|
||||
self.assertRaises(Exception, self.b.bootstrap, {'initdb': 1})
|
||||
|
||||
def test__process_user_options(self):
|
||||
def error_handler(msg):
|
||||
raise Exception(msg)
|
||||
|
||||
self.assertEqual(self.b.process_user_options('initdb', ['string'], (), error_handler), ['--string'])
|
||||
self.assertEqual(
|
||||
self.b.process_user_options(
|
||||
'initdb',
|
||||
[{'key': 'value'}],
|
||||
(), error_handler
|
||||
),
|
||||
['--key=value'])
|
||||
if sys.platform != 'win32':
|
||||
self.assertEqual(
|
||||
self.b.process_user_options(
|
||||
'initdb',
|
||||
[{'key': 'value with spaces'}],
|
||||
(), error_handler
|
||||
),
|
||||
["--key=value with spaces"])
|
||||
self.assertEqual(
|
||||
self.b.process_user_options(
|
||||
'initdb',
|
||||
[{'key': "'value with spaces'"}],
|
||||
(), error_handler
|
||||
),
|
||||
["--key=value with spaces"])
|
||||
self.assertEqual(
|
||||
self.b.process_user_options(
|
||||
'initdb',
|
||||
{'key': 'value with spaces'},
|
||||
(), error_handler
|
||||
),
|
||||
["--key=value with spaces"])
|
||||
self.assertEqual(
|
||||
self.b.process_user_options(
|
||||
'initdb',
|
||||
{'key': "'value with spaces'"},
|
||||
(), error_handler
|
||||
),
|
||||
["--key=value with spaces"])
|
||||
|
||||
@patch.object(CancellableSubprocess, 'call', Mock())
|
||||
@patch.object(Postgresql, 'is_running', Mock(return_value=True))
|
||||
@patch.object(Postgresql, 'data_directory_empty', Mock(return_value=False))
|
||||
|
||||
Reference in New Issue
Block a user