diff --git a/actions/table.go b/actions/table.go index a0cace6d..aede541f 100644 --- a/actions/table.go +++ b/actions/table.go @@ -338,6 +338,9 @@ func getInformSettings(nID string, nComparisons map[string]map[string]note.Field func setWidthOfColums(compare note.FieldComparison, c1, c2, c3, c4 int) (int, int, int, int) { if len(compare.ReflectMapKey) != 0 { if compare.ReflectFieldName == "OverrideParams" && len(compare.ActualValueJS) > c1 { + // in case of override content of ActualValueJS and + // ExpectedValueJS is the same, so one length check + // is sufficient c1 = len(compare.ActualValueJS) c1, c3, c4 = chkMaxWidthOfColums([]int{c1, c3, c4}) return c1, c2, c3, c4 diff --git a/actions/table_test.go b/actions/table_test.go index 2bea3628..2ed2e063 100644 --- a/actions/table_test.go +++ b/actions/table_test.go @@ -18,40 +18,62 @@ func TestSetWidthOfColums(t *testing.T) { w4 := 5 v1, v2, v3, v4 := setWidthOfColums(compare, w1, w2, w3, w4) if v1 != w1 { - t.Fatal(v1, w1) + t.Error(v1, w1) } if v2 != 16 { - t.Fatal(v2, w2) + t.Error(v2, w2) } if v3 != w3 || v4 != w4 { - t.Fatal(v3, w3, v4, w4) + t.Error(v3, w3, v4, w4) } compare = note.FieldComparison{ReflectFieldName: "OverrideParams", ReflectMapKey: "IO_SCHEDULER_sr0", ActualValueJS: "cfq", ExpectedValueJS: "cfq"} v1, v2, v3, v4 = setWidthOfColums(compare, w1, w2, w3, w4) if v1 != 3 { - t.Fatal(v1, w1) + t.Error(v1, w1) } if v2 != w2 || v3 != w3 || v4 != w4 { - t.Fatal(v2, w2, v3, w3, v4, w4) + t.Error(v2, w2, v3, w3, v4, w4) } compare = note.FieldComparison{ReflectFieldName: "SysctlParams", ReflectMapKey: "governor", ActualValueJS: "all-none", ExpectedValueJS: "all-performance"} v1, v2, v3, v4 = setWidthOfColums(compare, w1, w2, w3, w4) if v1 != w1 { - t.Fatal(v1, w1) + t.Error(v1, w1) } if v2 != 8 { - t.Fatal(v2, w2) + t.Error(v2, w2) } if v3 != 15 { - t.Fatal(v3, w3) + t.Error(v3, w3) } if v4 != 8 { - t.Fatal(v4, w4) + t.Error(v4, w4) } compare = note.FieldComparison{ReflectFieldName: "SysctlParams", ReflectMapKey: "", ActualValueJS: "all-none", ExpectedValueJS: "all-performance"} v1, v2, v3, v4 = setWidthOfColums(compare, w1, w2, w3, w4) if v1 != w1 || v2 != w2 || v3 != w3 || v4 != w4 { - t.Fatal(v1, w1, v2, w2, v3, w3, v4, w4) + t.Error(v1, w1, v2, w2, v3, w3, v4, w4) + } + compare = note.FieldComparison{ReflectFieldName: "SysctlParams", ReflectMapKey: "net.ipv4.ip_local_reserved_ports", ActualValueJS: "", ExpectedValueJS: "1089-1090,1095,1099,1200-1599,2000-2002,3200-3399,3500,3600-3699,3900-4001"} + v1, v2, v3, v4 = setWidthOfColums(compare, w1, w2, w3, w4) + if v1 != w1 { + t.Error(v1, w1) + } + if v2 != 32 { + t.Error(v2, w2) + } + if v3 != 30 { + t.Error(v3, w3) + } + if v4 != w4 { + t.Error(v4, w4) + } + compare = note.FieldComparison{ReflectFieldName: "OverrideParams", ReflectMapKey: "net.ipv4.ip_local_reserved_ports", ActualValueJS: "1089-1090,1095,1099,1200-1599,2000-2002,3200-3399,3500,3600-3699,3900-4001", ExpectedValueJS: "1089-1090,1095,1099,1200-1599,2000-2002,3200-3399,3500,3600-3699,3900-4001"} + v1, v2, v3, v4 = setWidthOfColums(compare, w1, w2, w3, w4) + if v1 != 30 { + t.Error(v1, w1) + } + if v2 != w2 || v3 != w3 || v4 != w4 { + t.Error(v2, w2, v3, w3, v4, w4) } }