Add getFTLPID() tests

Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
Christian König 2022-07-26 17:34:42 +02:00
parent 2651abbe6c
commit c8c4eb59b7
No known key found for this signature in database
GPG key ID: 4CDA6F249DD2B485

View file

@ -77,8 +77,8 @@ def test_getFTLAPIPortFile_and_getFTLAPIPort_custom(host):
''')
output = host.run('''
source /opt/pihole/utils.sh
FTL_API_PORT=$(getFTLAPIPortFile)
getFTLAPIPort "${FTL_API_PORT}"
FTL_API_PORT_FILE=$(getFTLAPIPortFile)
getFTLAPIPort "${FTL_API_PORT_FILE}"
''')
expected_stdout = '1234\n'
assert expected_stdout == output.stdout
@ -92,14 +92,26 @@ def test_getFTLPIDFile_default(host):
expected_stdout = '/run/pihole-FTL.pid\n'
assert expected_stdout == output.stdout
def test_getFTLPIDFile_custom(host):
def test_getFTLPID_default(host):
''' Confirms getFTLPID returns the default value if FTL is not running '''
output = host.run('''
source /opt/pihole/utils.sh
getFTLPID
''')
expected_stdout = '-1\n'
assert expected_stdout == output.stdout
def test_getFTLPIDFile_and_getFTLPID_custom(host):
''' Confirms getFTLPIDFile returns a custom PID file path '''
host.run('''
echo "PIDFILE=/tmp/pid.file" > /etc/pihole/pihole-FTL.conf
echo "1234" > /tmp/pid.file
''')
output = host.run('''
source /opt/pihole/utils.sh
getFTLPIDFile
FTL_PID_FILE=$(getFTLPIDFile)
getFTLPID "${FTL_PID_FILE}"
''')
expected_stdout = '/tmp/pid.file\n'
assert expected_stdout == output.stdout