Skip to content

Commit

Permalink
Add the all filter rekt test
Browse files Browse the repository at this point in the history
Signed-off-by: Leo Li <[email protected]>
  • Loading branch information
Leo6Leo committed Aug 28, 2023
1 parent eacaac5 commit a033cbb
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/experimental/features/new_trigger_filters/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,47 @@ func AnyFilterFeature(brokerName string) *feature.Feature {

return f
}

func AllFilterFeature(brokerName string) *feature.Feature {
f := feature.NewFeature()

eventContexts := []CloudEventsContext{
{
eventType: "exact.prefix.suffix.event.type",
shouldDeliver: true,
},
{
eventType: "not.event.type",
shouldDeliver: false,
},
}

filters := []eventingv1.SubscriptionsAPIFilter{
{
All: []eventingv1.SubscriptionsAPIFilter{
{
Exact: map[string]string{
"type": "exact.prefix.suffix.event.type",
},
},
{
Prefix: map[string]string{
"type": "exact.prefix",
},
},
{
Suffix: map[string]string{
"type": "suffix.event.type",
},
},
{
CESQL: "type LIKE 'exact.prefix.suffix%'",
},
},
},
}

f = newEventFilterFeature(eventContexts, filters, f, brokerName)

return f
}
16 changes: 16 additions & 0 deletions test/experimental/new_trigger_filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ func TestMTChannelBrokerAnyTriggerFilters(t *testing.T) {
env.Test(ctx, t, newfilters.AnyFilterFeature(brokerName))
}

func TestMTChannelBrokerAllTriggerFilters(t *testing.T) {
t.Parallel()

ctx, env := global.Environment(
knative.WithKnativeNamespace(system.Namespace()),
knative.WithLoggingConfig,
knative.WithTracingConfig,
k8s.WithEventListener,
environment.Managed(t),
)
brokerName := "default"

env.Prerequisite(ctx, t, InstallMTBroker(brokerName))
env.Test(ctx, t, newfilters.AllFilterFeature(brokerName))
}

func InstallMTBroker(name string) *feature.Feature {
f := feature.NewFeatureNamed("Multi-tenant channel-based broker")
f.Setup(fmt.Sprintf("Install broker %q", name), broker.Install(name, broker.WithEnvConfig()...))
Expand Down

0 comments on commit a033cbb

Please sign in to comment.