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 3, 2020
1 parent 8f44591 commit 3d3a7c3
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 @@ -56,3 +56,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 @@ -238,3 +238,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 @@ -289,3 +289,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 3d3a7c3

Please sign in to comment.