Skip to content

Commit

Permalink
Added testcase for v1alpha1/revision_validation.go
Browse files Browse the repository at this point in the history
  • Loading branch information
savitaashture committed Aug 28, 2019
1 parent c868670 commit 76386a2
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pkg/apis/serving/v1alpha1/revision_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,47 @@ func TestConcurrencyModelValidation(t *testing.T) {
}
}

func TestServingStateType(t *testing.T) {
tests := []struct {
name string
cm DeprecatedRevisionServingStateType
want *apis.FieldError
}{{
name: "active",
cm: DeprecatedRevisionServingStateActive,
want: nil,
}, {
name: "reserve",
cm: DeprecatedRevisionServingStateReserve,
want: nil,
}, {
name: "retired",
cm: DeprecatedRevisionServingStateRetired,
want: nil,
}, {
name: "empty",
cm: "",
want: nil,
}, {
name: "bogus",
cm: "bogus",
want: apis.ErrInvalidValue("bogus", apis.CurrentField),
}, {
name: "balderdash",
cm: "balderdash",
want: apis.ErrInvalidValue("balderdash", apis.CurrentField),
}}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
got := test.cm.Validate(context.Background())
if diff := cmp.Diff(test.want.Error(), got.Error()); diff != "" {
t.Errorf("Validate (-want, +got) = %v", diff)
}
})
}
}

func TestRevisionSpecValidation(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit 76386a2

Please sign in to comment.