Skip to content

Commit

Permalink
Enhance tests for v1b3 event type, new attrs (#8197)
Browse files Browse the repository at this point in the history
* 💄 Enhance tests for v1b3 event type, new attrs

Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>

* Update eventtype_validation_test.go

---------

Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>
  • Loading branch information
matzew authored Sep 20, 2024
1 parent 1708881 commit 2869c6c
Showing 1 changed file with 65 additions and 1 deletion.
66 changes: 65 additions & 1 deletion pkg/apis/eventing/v1beta3/eventtype_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,36 @@ func TestEventTypeSpecValidation(t *testing.T) {
ets *EventTypeSpec
want *apis.FieldError
}{{
name: "invalid eventtype type",
name: "invalid/empty eventtype",
ets: &EventTypeSpec{},
want: func() *apis.FieldError {
fe := apis.ErrMissingField("attributes.id", "attributes.source", "attributes.specversion", "attributes.type")
return fe
}(),
}, {
name: "partially invalid eventtype type",
ets: &EventTypeSpec{
Attributes: []EventAttributeDefinition{
{
Name: "source",
Value: testSource.String(),
Required: true,
},
{
Name: "specversion",
Value: "v1",
Required: true,
},
{
Name: "id",
Required: true,
},
},
},
want: func() *apis.FieldError {
fe := apis.ErrMissingField("attributes.type")
return fe
}(),
}, {
name: "valid eventtype",
ets: &EventTypeSpec{
Expand Down Expand Up @@ -86,6 +110,46 @@ func TestEventTypeSpecValidation(t *testing.T) {
},
},
},
}, {
name: "valid eventtype with extensions and optional attributes",
ets: &EventTypeSpec{
Reference: &duckv1.KReference{
APIVersion: "eventing.knative.dev/v1",
Kind: "Broker",
Name: "test-broker",
},
Attributes: []EventAttributeDefinition{
{
Name: "type",
Value: "event-type",
Required: true,
},
{
Name: "source",
Value: testSource.String(),
Required: true,
},
{
Name: "specversion",
Value: "v1",
Required: true,
},
{
Name: "subject",
Value: "foo.png",
Required: false,
},
{
Name: "customattribute",
Value: "value",
Required: false,
},
{
Name: "id",
Required: true,
},
},
},
},
}

Expand Down

0 comments on commit 2869c6c

Please sign in to comment.