Skip to content

Commit

Permalink
fixup! refactor(subp): Remove parameter 'combine_capture' (#4555)
Browse files Browse the repository at this point in the history
  • Loading branch information
holmanb committed Dec 1, 2023
1 parent 1fdb3d8 commit a716209
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions tests/unittests/config/test_cc_snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,33 +189,32 @@ def test_run_commands_on_non_list_or_dict(self):


@pytest.mark.allow_all_subp
def test_run_command_dict_sorted_as_command_script(caplog, tmp_path):
"""When commands are a dict, sort them and run."""
outfile = f"{tmp_path}/output.log"
cmd1 = f'echo "HI" >> {outfile}'
cmd2 = f'echo "MOM" >> {outfile}'
commands = {"02": cmd1, "01": cmd2}
run_commands(commands=commands)

expected_messages = ["Running user-provided snap commands"]
for message in expected_messages:
assert message in caplog.text
assert "MOM\nHI\n" == util.load_file(outfile)


@pytest.mark.allow_all_subp
def test_run_command_as_lists(caplog, tmp_path):
"""When commands are specified as a list, run them in order."""
outfile = "output.log"

cmd1 = f'echo "HI" >> {tmp_path}/{outfile}'
cmd2 = f'echo "MOM" >> {tmp_path}/{outfile}'
commands = [cmd1, cmd2]
run_commands(commands=commands)

assert "Running user-provided snap commands" in caplog.text
assert "HI\nMOM\n" == util.load_file(f"{tmp_path}/{outfile}")
assert "Non-snap commands in snap config:" in caplog.text
class TestCommands:
def test_run_command_dict_sorted_as_command_script(self, caplog, tmp_path):
"""When commands are a dict, sort them and run."""
outfile = f"{tmp_path}/output.log"
cmd1 = f'echo "HI" >> {outfile}'
cmd2 = f'echo "MOM" >> {outfile}'
commands = {"02": cmd1, "01": cmd2}
run_commands(commands=commands)

expected_messages = ["Running user-provided snap commands"]
for message in expected_messages:
assert message in caplog.text
assert "MOM\nHI\n" == util.load_file(outfile)

def test_run_command_as_lists(self, caplog, tmp_path):
"""When commands are specified as a list, run them in order."""
outfile = "output.log"

cmd1 = f'echo "HI" >> {tmp_path}/{outfile}'
cmd2 = f'echo "MOM" >> {tmp_path}/{outfile}'
commands = [cmd1, cmd2]
run_commands(commands=commands)

assert "Running user-provided snap commands" in caplog.text
assert "HI\nMOM\n" == util.load_file(f"{tmp_path}/{outfile}")
assert "Non-snap commands in snap config:" in caplog.text


@skipUnlessJsonSchema()
Expand Down

0 comments on commit a716209

Please sign in to comment.