mirror of https://github.com/knative/pkg.git
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:
parent
d8349b0909
commit
52b0e2938e
|
@ -180,6 +180,9 @@ func (s *Source) Validate(ctx context.Context) *apis.FieldError {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SourceSpec) 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")
|
return s.CloudEventOverrides.Validate(ctx).ViaField("ceOverrides")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,17 @@ func TestSourceValidate(t *testing.T) {
|
||||||
src *Source
|
src *Source
|
||||||
want *apis.FieldError
|
want *apis.FieldError
|
||||||
}{{
|
}{{
|
||||||
name: "empty source validation",
|
name: "nil source validation",
|
||||||
src: nil,
|
src: nil,
|
||||||
want: 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",
|
name: "empty source ceOverrides extensions validation",
|
||||||
src: &Source{Spec: SourceSpec{
|
src: &Source{Spec: SourceSpec{
|
||||||
|
|
Loading…
Reference in New Issue