diff --git a/config/main.py b/config/main.py index efb4ca41c2..9897e79ea3 100644 --- a/config/main.py +++ b/config/main.py @@ -6343,7 +6343,7 @@ def disable(ctx): def polling_int(ctx, interval): """Set polling-interval for counter-sampling (0 to disable)""" if interval not in range(5, 301) and interval != 0: - click.echo("Polling interval must be between 5-300 (0 to disable)") + ctx.fail("Polling interval must be between 5-300 (0 to disable)") config_db = ctx.obj['db'] sflow_tbl = config_db.get_table('SFLOW') diff --git a/tests/sflow_test.py b/tests/sflow_test.py index ecb2782534..ad6c53462c 100644 --- a/tests/sflow_test.py +++ b/tests/sflow_test.py @@ -182,6 +182,13 @@ def test_config_sflow_polling_interval(self): runner = CliRunner() obj = {'db':db.cfgdb} + # set to 500 out of range + result = runner.invoke(config.config.commands["sflow"]. + commands["polling-interval"], ["500"], obj=obj) + print(result.exit_code, result.output) + assert result.exit_code != 0 + assert "Polling interval must be between 5-300" in result.output + # set to 20 result = runner.invoke(config.config.commands["sflow"]. commands["polling-interval"], ["20"], obj=obj)