Skip to content

Commit

Permalink
test_mounts: expand happy path test for both happy paths (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
OddBloke authored Apr 16, 2020
1 parent 9d7b35c commit 0c5c736
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cloudinit/config/tests/test_mounts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This file is part of cloud-init. See LICENSE file for license information.
from unittest import mock

import pytest

from cloudinit.config.cc_mounts import create_swapfile


Expand All @@ -9,14 +11,18 @@

class TestCreateSwapfile:

@pytest.mark.parametrize('fstype', ('xfs', 'btrfs', 'ext4', 'other'))
@mock.patch(M_PATH + 'util.get_mount_info')
@mock.patch(M_PATH + 'util.subp')
def test_happy_path(self, m_subp, tmpdir):
def test_happy_path(self, m_subp, m_get_mount_info, fstype, tmpdir):
swap_file = tmpdir.join("swap-file")
fname = str(swap_file)

# Some of the calls to util.subp should create the swap file; this
# roughly approximates that
m_subp.side_effect = lambda *args, **kwargs: swap_file.write('')

m_get_mount_info.return_value = (mock.ANY, fstype)

create_swapfile(fname, '')
assert mock.call(['mkswap', fname]) in m_subp.call_args_list

0 comments on commit 0c5c736

Please sign in to comment.