Add unit test for commit 22abe9081
Commit22abe9081
fixed a bug in commitd7bd65e8e
which we could have found the first time with a simple unit test. This change adds the unit test to cover that new error handling block. Related-Bug: #1398078 Change-Id: I86d2fd477f3ae5590c5f079a4c806d1f50eb96d0
This commit is contained in:
parent
40995e4434
commit
eb20e9e500
|
@ -18,6 +18,7 @@ import shutil
|
|||
import string
|
||||
import tempfile
|
||||
|
||||
from oslo.concurrency import processutils
|
||||
from oslo.config import cfg
|
||||
|
||||
from cinder.brick.iscsi import iscsi
|
||||
|
@ -157,6 +158,16 @@ class TgtAdmTestCase(test.TestCase, TargetAdminTestCase):
|
|||
self.assertEqual(target_helper._get_target_chap_auth(self.target_name),
|
||||
(self.chap_username, self.chap_password))
|
||||
|
||||
def fake_execute(self, *cmd, **kwargs):
|
||||
self.cmds.append(string.join(cmd))
|
||||
# Tests that if tgtadm --op show fails with 'target already exists',
|
||||
# we handle it gracefully and continue.
|
||||
if 'tgtadm' in cmd and '--op' in cmd and 'show' in cmd:
|
||||
raise processutils.ProcessExecutionError(
|
||||
stderr='tgtadm: this target already exists')
|
||||
else:
|
||||
return "", None
|
||||
|
||||
|
||||
class IetAdmTestCase(test.TestCase, TargetAdminTestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue