Skip to content

Commit fc7a464

Browse files
committed
fix: [TKC-4714] add event matching so group-agnostic listeners receive env-scoped events (#6935)
1 parent 4681c7c commit fc7a464

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

pkg/api/v1/testkube/model_event_extended.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func (e Event) Log() []any {
158158
}
159159

160160
func (e Event) Valid(groupId, selector string, types []EventType) (matchedTypes []EventType, valid bool) {
161-
if e.GroupId != groupId {
161+
if groupId != "" && e.GroupId != groupId {
162162
return nil, false
163163
}
164164

pkg/api/v1/testkube/model_event_extended_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ func TestEmitter_IsValidEvent_ForTestWorkflow(t *testing.T) {
5656
assert.True(t, valid)
5757
})
5858

59+
t.Run("should treat empty group as wildcard", func(t *testing.T) {
60+
t.Parallel()
61+
62+
// given
63+
execution := &TestWorkflowExecution{Workflow: &TestWorkflow{}}
64+
e := Event{Type_: EventStartTestWorkflow, TestWorkflowExecution: execution, GroupId: "env-1"}
65+
66+
// when
67+
types, valid := e.Valid("", "", AllEventTypes)
68+
69+
// then
70+
assert.Equal(t, []EventType{START_TESTWORKFLOW_EventType}, types)
71+
assert.True(t, valid)
72+
})
73+
5974
t.Run("should pass events with become events", func(t *testing.T) {
6075
t.Parallel()
6176

0 commit comments

Comments
 (0)