1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-12-22 14:58:08 +00:00

switching testinfra's Docker run from dash to bash

This commit is contained in:
diginc 2016-11-02 23:58:54 -05:00
parent 699e299345
commit a5a067d50f
2 changed files with 15 additions and 2 deletions

View File

@ -8,6 +8,20 @@ check_output = testinfra.get_backend(
@pytest.fixture @pytest.fixture
def Pihole(Docker): def Pihole(Docker):
''' used to contain some script stubbing, now pretty much an alias ''' ''' used to contain some script stubbing, now pretty much an alias '''
def run_bash(self, command, *args, **kwargs):
cmd = self.get_command(command, *args)
if self.user is not None:
out = self.run_local(
"docker exec -u %s %s /bin/bash -c %s",
self.user, self.name, cmd)
else:
out = self.run_local(
"docker exec %s /bin/bash -c %s", self.name, cmd)
out.command = self.encode(cmd)
return out
funcType = type(Docker.run)
Docker.run = funcType(run_bash, Docker, testinfra.backend.docker.DockerBackend)
return Docker return Docker
@pytest.fixture @pytest.fixture

View File

@ -69,11 +69,10 @@ def test_configureFirewall_firewalld_no_errors(Pihole):
''' confirms firewalld rules are applied when appopriate ''' ''' confirms firewalld rules are applied when appopriate '''
mock_command('firewall-cmd', '0', Pihole) mock_command('firewall-cmd', '0', Pihole)
configureFirewall = Pihole.run(''' configureFirewall = Pihole.run('''
bash -c "
PHTEST=TRUE PHTEST=TRUE
source /opt/pihole/basic-install.sh source /opt/pihole/basic-install.sh
configureFirewall configureFirewall
" ''') ''')
expected_stdout = '::: Configuring firewalld for httpd and dnsmasq.' expected_stdout = '::: Configuring firewalld for httpd and dnsmasq.'
assert expected_stdout in configureFirewall.stdout assert expected_stdout in configureFirewall.stdout
firewall_calls = Pihole.run('cat /var/log/firewall-cmd').stdout firewall_calls = Pihole.run('cat /var/log/firewall-cmd').stdout