switching testinfra's Docker run from dash to bash

pull/899/head
diginc 8 years ago
parent 699e299345
commit a5a067d50f

@ -8,6 +8,20 @@ check_output = testinfra.get_backend(
@pytest.fixture
def Pihole(Docker):
''' 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
@pytest.fixture

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

Loading…
Cancel
Save