Source validation fixes (#2285)

* added error case when ceOverrides is null

* added test for empty source spec ceOverrides validation case

* added test for empty spec
This commit is contained in:
Gabriel Freites 2021-09-15 13:31:08 -05:00 committed by GitHub
parent d8349b0909
commit 52b0e2938e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -180,6 +180,9 @@ func (s *Source) Validate(ctx context.Context) *apis.FieldError {
}
func (s *SourceSpec) Validate(ctx context.Context) *apis.FieldError {
if s.CloudEventOverrides == nil {
return nil
}
return s.CloudEventOverrides.Validate(ctx).ViaField("ceOverrides")
}

View File

@ -29,9 +29,17 @@ func TestSourceValidate(t *testing.T) {
src *Source
want *apis.FieldError
}{{
name: "empty source validation",
name: "nil source validation",
src: nil,
want: nil,
}, {
name: "nil source spec validation",
src: &Source{},
want: nil,
}, {
name: "empty source spec validation",
src: &Source{Spec: SourceSpec{}},
want: nil,
}, {
name: "empty source ceOverrides extensions validation",
src: &Source{Spec: SourceSpec{