@@ -154,6 +154,32 @@ def test_add_data_cache(self):
154154 _ERROR ,
155155 )
156156
157+ def test_add_data_cache_mock_check (self ):
158+ """
159+ Test that adding 1 data device that is already in the cache tier raises
160+ an exception.
161+ """
162+ devices = _DEVICE_STRATEGY ()
163+ command_line = (
164+ ["--propagate" , "pool" , "init-cache" ] + [self ._POOLNAME ] + devices
165+ )
166+ RUNNER (command_line )
167+ # isort: LOCAL
168+ import stratis_cli # pylint: disable=import-outside-toplevel
169+
170+ with patch .object (
171+ # pylint: disable=protected-access
172+ stratis_cli ._actions ._pool , # pyright: ignore
173+ "_check_opposite_tier" ,
174+ autospec = True ,
175+ return_value = None ,
176+ ):
177+ self .check_error (
178+ StratisCliEngineError ,
179+ self ._MENU + [self ._POOLNAME ] + devices ,
180+ _ERROR ,
181+ )
182+
157183 def test_add_data_cache_2 (self ):
158184 """
159185 Test that adding multiple (2) data devices that are already in the cache tier raises
@@ -281,6 +307,24 @@ def test_add_cache_data(self):
281307 command_line = self ._MENU + [self ._POOLNAME ] + self ._DEVICES
282308 self .check_error (StratisCliInUseOtherTierError , command_line , _ERROR )
283309
310+ def test_add_cache_data_mock_check (self ):
311+ """
312+ Test that adding 1 cache device that is already in the data tier raises
313+ an exception.
314+ """
315+ command_line = self ._MENU + [self ._POOLNAME ] + self ._DEVICES
316+ # isort: LOCAL
317+ import stratis_cli # pylint: disable=import-outside-toplevel
318+
319+ with patch .object (
320+ # pylint: disable=protected-access
321+ stratis_cli ._actions ._pool , # pyright: ignore
322+ "_check_opposite_tier" ,
323+ autospec = True ,
324+ return_value = None ,
325+ ):
326+ self .check_error (StratisCliEngineError , command_line , _ERROR )
327+
284328
285329class AddCacheTestCase2 (SimTestCase ):
286330 """
0 commit comments