lambda/event: fix TargetIDSet.IsEmpty and add regression test

Signed-off-by: AleksaMCode <aleksamcode@gmail.com>
This commit is contained in:
AleksaMCode
2026-09-17 22:03:11 +02:00
parent 2fde3cf535
commit efd5698597
2 changed files with 17 additions and 1 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ type TargetIDSet map[TargetID]struct{}
// IsEmpty returns true if the set is empty.
func (set TargetIDSet) IsEmpty() bool {
return len(set) != 0
return len(set) == 0
}
// Clone - returns copy of this set.
@@ -22,6 +22,22 @@ import (
"testing"
)
func TestTargetIDSetIsEmpty(t *testing.T) {
testCases := []struct {
set TargetIDSet
expected bool
}{
{NewTargetIDSet(), true},
{NewTargetIDSet(TargetID{"1", "webhook"}), false},
}
for i, testCase := range testCases {
if got := testCase.set.IsEmpty(); got != testCase.expected {
t.Fatalf("test %v: expected: %v, got: %v", i+1, testCase.expected, got)
}
}
}
func TestTargetIDSetClone(t *testing.T) {
testCases := []struct {
set TargetIDSet