Skip to content

Commit

Permalink
💄 Enhance tests for v1b3 event type, new attrs
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Wessendorf <[email protected]>
  • Loading branch information
matzew committed Sep 19, 2024
1 parent 1708881 commit d478674
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 eventtype type, missing type",
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 d478674

Please sign in to comment.