Skip to content

Commit

Permalink
Update iscsi tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciopoppe committed Jun 15, 2021
1 parent b94e435 commit e979cbf
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions pkg/server/iscsi/impl/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/kubernetes-csi/csi-proxy/client/api/iscsi/v1alpha1"
"github.com/kubernetes-csi/csi-proxy/client/api/iscsi/v1alpha2"
internal "github.com/kubernetes-csi/csi-proxy/pkg/server/iscsi/impl"
v1alpha1_internal "github.com/kubernetes-csi/csi-proxy/pkg/server/iscsi/impl/v1alpha1"
v1alpha2_internal "github.com/kubernetes-csi/csi-proxy/pkg/server/iscsi/impl/v1alpha2"
"github.com/kubernetes-csi/csi-proxy/pkg/server/iscsi/impl"
v1alpha1_impl "github.com/kubernetes-csi/csi-proxy/pkg/server/iscsi/impl/v1alpha1"
v1alpha2_impl "github.com/kubernetes-csi/csi-proxy/pkg/server/iscsi/impl/v1alpha2"
"google.golang.org/protobuf/testing/protocmp"
)

func TestListTargetPortals_Conversion_v1alpha1(t *testing.T) {
testCases := []struct {
in *internal.ListTargetPortalsResponse
in *impl.ListTargetPortalsResponse
wantOut *v1alpha1.ListTargetPortalsResponse
wantErr bool
}{
{
in: &internal.ListTargetPortalsResponse{
TargetPortals: []*internal.TargetPortal{{TargetPort: 3260, TargetAddress: "test.iqn"}},
in: &impl.ListTargetPortalsResponse{
TargetPortals: []*impl.TargetPortal{{TargetPort: 3260, TargetAddress: "test.iqn"}},
},
wantOut: &v1alpha1.ListTargetPortalsResponse{
TargetPortals: []*v1alpha1.TargetPortal{{TargetPort: 3260, TargetAddress: "test.iqn"}},
},
wantErr: false,
},
{
in: &internal.ListTargetPortalsResponse{
TargetPortals: []*internal.TargetPortal{{TargetPort: 3260, TargetAddress: "test.iqn"},
in: &impl.ListTargetPortalsResponse{
TargetPortals: []*impl.TargetPortal{{TargetPort: 3260, TargetAddress: "test.iqn"},
{TargetPort: 1000, TargetAddress: "test.iqn.2"},
},
},
Expand All @@ -41,15 +41,15 @@ func TestListTargetPortals_Conversion_v1alpha1(t *testing.T) {
wantErr: false,
},
{
in: &internal.ListTargetPortalsResponse{},
in: &impl.ListTargetPortalsResponse{},
wantOut: &v1alpha1.ListTargetPortalsResponse{},
wantErr: false,
},
}

for _, tc := range testCases {
got := v1alpha1.ListTargetPortalsResponse{}
err := v1alpha1_internal.Convert_internal_ListTargetPortalsResponse_To_v1alpha1_ListTargetPortalsResponse(tc.in, &got)
err := v1alpha1_impl.Convert_impl_ListTargetPortalsResponse_To_v1alpha1_ListTargetPortalsResponse(tc.in, &got)
if tc.wantErr && err == nil {
t.Errorf("Expected error but returned a nil error")
}
Expand All @@ -64,22 +64,22 @@ func TestListTargetPortals_Conversion_v1alpha1(t *testing.T) {

func TestListTargetPortals_Conversion_v1alpha2(t *testing.T) {
testCases := []struct {
in *internal.ListTargetPortalsResponse
in *impl.ListTargetPortalsResponse
wantOut *v1alpha2.ListTargetPortalsResponse
wantErr bool
}{
{
in: &internal.ListTargetPortalsResponse{
TargetPortals: []*internal.TargetPortal{{TargetPort: 3260, TargetAddress: "test.iqn"}},
in: &impl.ListTargetPortalsResponse{
TargetPortals: []*impl.TargetPortal{{TargetPort: 3260, TargetAddress: "test.iqn"}},
},
wantOut: &v1alpha2.ListTargetPortalsResponse{
TargetPortals: []*v1alpha2.TargetPortal{{TargetPort: 3260, TargetAddress: "test.iqn"}},
},
wantErr: false,
},
{
in: &internal.ListTargetPortalsResponse{
TargetPortals: []*internal.TargetPortal{{TargetPort: 3260, TargetAddress: "test.iqn"},
in: &impl.ListTargetPortalsResponse{
TargetPortals: []*impl.TargetPortal{{TargetPort: 3260, TargetAddress: "test.iqn"},
{TargetPort: 1000, TargetAddress: "test.iqn.2"},
},
},
Expand All @@ -91,15 +91,15 @@ func TestListTargetPortals_Conversion_v1alpha2(t *testing.T) {
wantErr: false,
},
{
in: &internal.ListTargetPortalsResponse{},
in: &impl.ListTargetPortalsResponse{},
wantOut: &v1alpha2.ListTargetPortalsResponse{},
wantErr: false,
},
}

for _, tc := range testCases {
got := v1alpha2.ListTargetPortalsResponse{}
err := v1alpha2_internal.Convert_internal_ListTargetPortalsResponse_To_v1alpha2_ListTargetPortalsResponse(tc.in, &got)
err := v1alpha2_impl.Convert_impl_ListTargetPortalsResponse_To_v1alpha2_ListTargetPortalsResponse(tc.in, &got)
if tc.wantErr && err == nil {
t.Errorf("Expected error but returned a nil error")
}
Expand Down

0 comments on commit e979cbf

Please sign in to comment.