Skip to content

Commit

Permalink
Tests for bad types
Browse files Browse the repository at this point in the history
  • Loading branch information
aliok committed Jul 6, 2020
1 parent 3804f5e commit d7d1dc5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/apis/duck/v1/subscribable_types_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,15 @@ func TestSubscribableStatusConversionBadType(t *testing.T) {
t.Errorf("ConvertFrom() = %#v, wanted error", good)
}
}

func TestSubscriberSpecConversionBadType(t *testing.T) {
good, bad := &SubscriberSpec{}, &SubscriberSpec{}

if err := good.ConvertTo(context.Background(), bad); err == nil {
t.Errorf("ConvertTo() = %#v, wanted error", bad)
}

if err := good.ConvertFrom(context.Background(), bad); err == nil {
t.Errorf("ConvertFrom() = %#v, wanted error", good)
}
}
12 changes: 12 additions & 0 deletions pkg/apis/duck/v1alpha1/subscribable_types_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,15 @@ func TestSubscribableTypeStatusConversionBadType(t *testing.T) {
t.Errorf("ConvertFrom() = %#v, wanted error", good)
}
}

func TestSubscriberSpecStatusConversionBadType(t *testing.T) {
good, bad := &SubscriberSpec{}, &SubscriberSpec{}

if err := good.ConvertTo(context.Background(), bad); err == nil {
t.Errorf("ConvertTo() = %#v, wanted error", bad)
}

if err := good.ConvertFrom(context.Background(), bad); err == nil {
t.Errorf("ConvertFrom() = %#v, wanted error", good)
}
}
12 changes: 12 additions & 0 deletions pkg/apis/duck/v1beta1/subscribable_types_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,15 @@ func TestSubscribableStatusConversionBadType(t *testing.T) {
t.Errorf("ConvertFrom() = %#v, wanted error", good)
}
}

func TestSubscriberSpecConversionBadType(t *testing.T) {
good, bad := &SubscriberSpec{}, &SubscriberSpec{}

if err := good.ConvertTo(context.Background(), bad); err == nil {
t.Errorf("ConvertTo() = %#v, wanted error", bad)
}

if err := good.ConvertFrom(context.Background(), bad); err == nil {
t.Errorf("ConvertFrom() = %#v, wanted error", good)
}
}

0 comments on commit d7d1dc5

Please sign in to comment.