Skip to content

Commit

Permalink
Add unit test case to resolve coverage error
Browse files Browse the repository at this point in the history
  • Loading branch information
PJHsieh committed Jul 8, 2024
1 parent db77a05 commit dd2e2cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/portconfig
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ class portconfig(object):
raise Exception("Invalid port %s" % (port))

if self.is_rj45_port:
raise Exception("Setting RJ45 ports' link-training is not supported")
print("Setting RJ45 ports' link-training is not supported")
exit(1)

if self.verbose:
print("Setting link-training %s on port %s" % (mode, port))
Expand Down
5 changes: 5 additions & 0 deletions tests/config_lt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def test_config_link_training(self, ctx):
result = self.basic_check("link-training", ["PortChannel0001", "on"], ctx, operator.ne)
assert 'Invalid port PortChannel0001' in result.output

result = self.basic_check("link-training", ["Ethernet16", "on"], ctx, operator.ne)
assert "Setting RJ45 ports' link-training is not supported" in result.output
result = self.basic_check("link-training", ["Ethernet16", "off"], ctx, operator.ne)
assert "Setting RJ45 ports' link-training is not supported" in result.output

def basic_check(self, command_name, para_list, ctx, op=operator.eq, expect_result=0):
runner = CliRunner()
result = runner.invoke(config.config.commands["interface"].commands[command_name], para_list, obj = ctx)
Expand Down

0 comments on commit dd2e2cf

Please sign in to comment.