Skip to content

Commit c5d00ae

Browse files
authored
[pfcwd] Fix the return code in invalid case (#1691)
Signed-off-by: Neetha John <nejo@microsoft.com> Fixes #1690 What I did Set the correct return code when pfcwd command is specified with invalid options How to verify it Modified the unit test to check for the correct return code and ran them and they passed
1 parent 57dc403 commit c5d00ae

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pfcwd/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def start(self, action, restoration_time, ports, detection_time):
242242
click.echo("Failed to run command, invalid options:")
243243
for opt in invalid_ports:
244244
click.echo(opt)
245-
exit()
245+
exit(1)
246246
self.start_cmd(action, restoration_time, ports, detection_time)
247247

248248

tests/pfcwd_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def test_pfcwd_start_ports_invalid(self):
255255
obj=db
256256
)
257257
print(result.output)
258-
assert result.exit_code == 0
258+
assert result.exit_code == 1
259259
assert result.output == pfcwd_show_start_config_output_fail
260260

261261
@classmethod
@@ -447,7 +447,7 @@ def test_pfcwd_start_ports_masic_invalid(self):
447447
obj=db
448448
)
449449
print(result.output)
450-
assert result.exit_code == 0
450+
assert result.exit_code == 1
451451
assert result.output == show_pfc_config_start_fail
452452

453453
# get config after the command, config shouldn't change
@@ -500,4 +500,4 @@ def teardown_class(cls):
500500
import mock_tables.mock_single_asic
501501
importlib.reload(mock_tables.mock_single_asic)
502502
import pfcwd.main
503-
importlib.reload(pfcwd.main)
503+
importlib.reload(pfcwd.main)

0 commit comments

Comments
 (0)