Align rule table display widths

This commit is contained in:
2026-04-17 12:17:00 +08:00
parent 87ee5283c8
commit 818c52c10d
6 changed files with 29 additions and 16 deletions

View File

@@ -89,6 +89,11 @@ del_count=$(grep -Ec ' -D ' "${IPTABLES_MOCK_LOG}")
assert_eq '16' "${del_count}" 'deleting both/both rule should emit sixteen delete commands'
assert_eq '0' "$(storage_count)" 'cmd_delete_uuid should remove rule from storage'
reset_mock_state
cmd_add_batch tcp 9080 127.0.0.1 98 4 'desc-mark' >/dev/null
mapfile -t list_lines < <(cmd_list 0)
assert_eq "$(display_width "${list_lines[0]%%描述*}")" "$(display_width "${list_lines[1]%%desc-mark*}")" 'cmd_list should align description column by display width'
reset_mock_state
export IPTABLES_MOCK_FAIL_ON_N=2
assert_eq '1' "$(status_of cmd_add_batch tcp 9000 127.0.0.1 90 4 'rollback')" 'cmd_add_batch should fail when iptables mock injects an error'