internal: fix MaxSizeSubjectsListForLog off-by-one when maxToDisplay is 0
The loop appended before checking the length, so with maxToDisplay=0 one domain leaked into the output before the break check. Reorder so the length check comes first. Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>pull/7227/head
parent
5bdfdeb848
commit
d9ca71a718
|
|
@ -90,12 +90,8 @@ func TestMaxSizeSubjectsListForLog(t *testing.T) {
|
|||
"b.com": {},
|
||||
},
|
||||
maxToDisplay: 0,
|
||||
// BUG: When maxToDisplay is 0, code still appends one domain
|
||||
// because append happens before the break check in the loop.
|
||||
// Expected behavior: 1 item (just suffix). Actual: 2 items
|
||||
// (1 leaked domain + suffix).
|
||||
wantLen: 2,
|
||||
wantSuffix: true,
|
||||
wantLen: 1,
|
||||
wantSuffix: true,
|
||||
},
|
||||
{
|
||||
name: "single subject with max 1",
|
||||
|
|
|
|||
Loading…
Reference in New Issue