Skip to content

Commit

Permalink
Adding mock to TestListSnapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharya committed May 8, 2019
1 parent fdca564 commit 6c0eb0d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/driver/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1294,9 +1294,11 @@ func TestListSnapshots(t *testing.T) {
MaxEntries: 4,
}

ctx := context.Background()
mockCtl := gomock.NewController(t)
defer mockCtl.Finish()
mockCloud := mocks.NewMockCloud(mockCtl)
mockCloud.EXPECT().ListSnapshots(gomock.Eq(ctx), gomock.Eq(""), gomock.Eq(int64(4)), gomock.Eq("")).Return(nil, cloud.ErrInvalidMaxResults)

awsDriver := controllerService{cloud: mockCloud}
if _, err := awsDriver.ListSnapshots(context.Background(), req); err != nil {
Expand All @@ -1305,10 +1307,10 @@ func TestListSnapshots(t *testing.T) {
t.Fatalf("Could not get error status code from error: %v", srvErr)
}
if srvErr.Code() != codes.InvalidArgument {
t.Fatalf("Expected error code %d, got %d message %s", codes.Internal, srvErr.Code(), srvErr.Message())
t.Fatalf("Expected error code %d, got %d message %s", codes.InvalidArgument, srvErr.Code(), srvErr.Message())
}
} else {
t.Fatalf("Expected error code %d, got no error", codes.Internal)
t.Fatalf("Expected error code %d, got no error", codes.InvalidArgument)
}
},
},
Expand Down

0 comments on commit 6c0eb0d

Please sign in to comment.