← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~jasonzio/cloud-init:fixmounterrormatch into cloud-init:master

 

Thank you for this branch.


 I'm trying to decide if it's worth noting the SLES/RHEL differences by extending the existing unit test test_ntfs_mount_errors_true in tests/unittests/test_datasource/test_azure.py.

I like getting test coverage to explain what 'mocked' expectation are and why to give future-us context on what to worry about with a change.


How's this patch look?

diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
index 4c5c6c1..b4bc48d 100644
--- a/tests/unittests/test_datasource/test_azure.py
+++ b/tests/unittests/test_datasource/test_azure.py
@@ -1510,21 +1510,20 @@ class TestCanDevBeReformatted(CiTestCase):
                     '/dev/sda1': {'num': 1, 'fs': 'ntfs', 'files': []}
                 }}})
 
-        err = ("Unexpected error while running command.\n",
-               "Command: ['mount', '-o', 'ro,sync', '-t', 'auto', ",
-               "'/dev/sda1', '/fake-tmp/dir']\n"
-               "Exit code: 32\n"
-               "Reason: -\n"
-               "Stdout: -\n"
-               "Stderr: mount: unknown filesystem type 'ntfs'")
-        self.m_mount_cb.side_effect = MountFailedError(
-            'Failed mounting %s to %s due to: %s' %
-            ('/dev/sda', '/fake-tmp/dir', err))
-
-        value, msg = dsaz.can_dev_be_reformatted('/dev/sda',
-                                                 preserve_ntfs=False)
-        self.assertTrue(value)
-        self.assertIn('cannot mount NTFS, assuming', msg)
+        error_msgs = [
+            "Stderr: mount: unknown filesystem type 'ntfs'",  # RHEL
+            "Stderr: mount: /dev/sdb1: unknown filesystem type 'ntfs'" # SLES
+        ]
+
+        for err_msg in error_msgs:
+            self.m_mount_cb.side_effect = MountFailedError(
+                'Failed mounting %s to %s due to: %s' %
+                ('/dev/sda', '/fake-tmp/dir', err_msg))
+
+            value, msg = dsaz.can_dev_be_reformatted(
+                '/dev/sda', preserve_ntfs=False)
+            self.assertTrue(value)
+            self.assertIn('cannot mount NTFS, assuming', msg)
 
     def test_never_destroy_ntfs_config_false(self):
         """Normally formattable situation with never_destroy_ntfs set."""






-- 
https://code.launchpad.net/~jasonzio/cloud-init/+git/cloud-init/+merge/357669
Your team cloud-init commiters is requested to review the proposed merge of ~jasonzio/cloud-init:fixmounterrormatch into cloud-init:master.


Follow ups

References