refactor: rename GetShares to GetSharesForResource

Rename this method to make more clear what it is about.
This commit is contained in:
Jannik Stehle
2024-05-14 10:30:42 +02:00
committed by Ralf Haferkamp
parent 716e513006
commit 779bf33fcc
3 changed files with 32 additions and 32 deletions
@@ -84,8 +84,8 @@ type (
// GetShare returns the share
GetShare(ctx context.Context, shareID *collaboration.ShareId) (*collaboration.ReceivedShare, error)
// GetShares returns all shares for a given resourceID
GetShares(ctx context.Context, resourceID *storageprovider.ResourceId, filters []*collaboration.Filter) ([]*collaboration.ReceivedShare, error)
// GetSharesForResource returns all shares for a given resourceID
GetSharesForResource(ctx context.Context, resourceID *storageprovider.ResourceId, filters []*collaboration.Filter) ([]*collaboration.ReceivedShare, error)
}
)
@@ -123,8 +123,8 @@ func (s DrivesDriveItemService) GetShare(ctx context.Context, shareID *collabora
return getReceivedShareResponse.GetShare(), errorcode.FromCS3Status(getReceivedShareResponse.GetStatus(), err)
}
// GetShares returns all shares for a given resourceID
func (s DrivesDriveItemService) GetShares(ctx context.Context, resourceID *storageprovider.ResourceId, filters []*collaboration.Filter) ([]*collaboration.ReceivedShare, error) {
// GetSharesForResource returns all shares for a given resourceID
func (s DrivesDriveItemService) GetSharesForResource(ctx context.Context, resourceID *storageprovider.ResourceId, filters []*collaboration.Filter) ([]*collaboration.ReceivedShare, error) {
// Find all accepted shares for this resource
gatewayClient, err := s.gatewaySelector.Next()
if err != nil {
@@ -214,7 +214,7 @@ func (s DrivesDriveItemService) UnmountShare(ctx context.Context, shareID *colla
return err
}
availableShares, err := s.GetShares(ctx, share.GetShare().GetResourceId(), []*collaboration.Filter{
availableShares, err := s.GetSharesForResource(ctx, share.GetShare().GetResourceId(), []*collaboration.Filter{
{
Type: collaboration.Filter_TYPE_STATE,
Term: &collaboration.Filter_State{
@@ -246,7 +246,7 @@ func (s DrivesDriveItemService) MountShare(ctx context.Context, resourceID *stor
name = filepath.Clean(name)
}
availableShares, err := s.GetShares(ctx, resourceID, []*collaboration.Filter{
availableShares, err := s.GetSharesForResource(ctx, resourceID, []*collaboration.Filter{
{
Type: collaboration.Filter_TYPE_STATE,
Term: &collaboration.Filter_State{
@@ -360,7 +360,7 @@ func (api DrivesDriveItemApi) GetDriveItem(w http.ResponseWriter, r *http.Reques
return
}
availableShares, err := api.drivesDriveItemService.GetShares(r.Context(), share.GetShare().GetResourceId(), nil)
availableShares, err := api.drivesDriveItemService.GetSharesForResource(r.Context(), share.GetShare().GetResourceId(), nil)
if err != nil {
api.logger.Debug().Err(err).Msg(ErrNoShares.Error())
ErrNoShares.Render(w, r)
@@ -414,7 +414,7 @@ func (api DrivesDriveItemApi) UpdateDriveItem(w http.ResponseWriter, r *http.Req
return
}
availableShares, err := api.drivesDriveItemService.GetShares(r.Context(), share.GetShare().GetResourceId(), nil)
availableShares, err := api.drivesDriveItemService.GetSharesForResource(r.Context(), share.GetShare().GetResourceId(), nil)
if err != nil {
api.logger.Debug().Err(err).Msg(ErrNoShares.Error())
ErrNoShares.Render(w, r)
@@ -58,9 +58,9 @@ var _ = Describe("DrivesDriveItemService", func() {
})
}
var _ = Describe("GetShares", func() {
var _ = Describe("GetSharesForResource", func() {
failOnFailingGatewayClientRotation(func() error {
_, err := drivesDriveItemService.GetShares(context.Background(), nil, nil)
_, err := drivesDriveItemService.GetSharesForResource(context.Background(), nil, nil)
return err
})
@@ -83,7 +83,7 @@ var _ = Describe("DrivesDriveItemService", func() {
}).
Once()
_, _ = drivesDriveItemService.GetShares(context.Background(), resourceID, []*collaborationv1beta1.Filter{
_, _ = drivesDriveItemService.GetSharesForResource(context.Background(), resourceID, []*collaborationv1beta1.Filter{
{
Type: collaborationv1beta1.Filter_TYPE_STATE,
Term: &collaborationv1beta1.Filter_State{
@@ -101,7 +101,7 @@ var _ = Describe("DrivesDriveItemService", func() {
Return(nil, someErr).
Once()
_, err := drivesDriveItemService.GetShares(context.Background(), &storageprovider.ResourceId{}, []*collaborationv1beta1.Filter{})
_, err := drivesDriveItemService.GetSharesForResource(context.Background(), &storageprovider.ResourceId{}, []*collaborationv1beta1.Filter{})
Expect(err).To(MatchError(someErr))
})
@@ -112,7 +112,7 @@ var _ = Describe("DrivesDriveItemService", func() {
Return(nil, nil).
Once()
_, err := drivesDriveItemService.GetShares(context.Background(), &storageprovider.ResourceId{}, []*collaborationv1beta1.Filter{})
_, err := drivesDriveItemService.GetSharesForResource(context.Background(), &storageprovider.ResourceId{}, []*collaborationv1beta1.Filter{})
Expect(err).To(MatchError(svc.ErrNoShares))
})
@@ -131,7 +131,7 @@ var _ = Describe("DrivesDriveItemService", func() {
}, nil).
Once()
shares, err := drivesDriveItemService.GetShares(context.Background(), &storageprovider.ResourceId{}, []*collaborationv1beta1.Filter{})
shares, err := drivesDriveItemService.GetSharesForResource(context.Background(), &storageprovider.ResourceId{}, []*collaborationv1beta1.Filter{})
Expect(err).To(BeNil())
Expect(shares).To(Equal(givenShares))
})
@@ -616,7 +616,7 @@ var _ = Describe("DrivesDriveItemApi", func() {
drivesDriveItemProvider.
EXPECT().
GetShares(mock.Anything, mock.Anything, mock.Anything).
GetSharesForResource(mock.Anything, mock.Anything, mock.Anything).
Return(nil, errors.New("some error")).
Once()
@@ -649,7 +649,7 @@ var _ = Describe("DrivesDriveItemApi", func() {
drivesDriveItemProvider.
EXPECT().
GetShares(mock.Anything, mock.Anything, mock.Anything).
GetSharesForResource(mock.Anything, mock.Anything, mock.Anything).
Return(nil, nil).
Once()
@@ -693,7 +693,7 @@ var _ = Describe("DrivesDriveItemApi", func() {
drivesDriveItemProvider.
EXPECT().
GetShares(mock.Anything, mock.Anything, mock.Anything).
GetSharesForResource(mock.Anything, mock.Anything, mock.Anything).
Return([]*collaborationv1beta1.ReceivedShare{}, nil).
Once()
@@ -772,7 +772,7 @@ var _ = Describe("DrivesDriveItemApi", func() {
drivesDriveItemProvider.
EXPECT().
GetShares(mock.Anything, mock.Anything, mock.Anything).
GetSharesForResource(mock.Anything, mock.Anything, mock.Anything).
Return([]*collaborationv1beta1.ReceivedShare{share}, nil).
Once()
@@ -864,7 +864,7 @@ var _ = Describe("DrivesDriveItemApi", func() {
drivesDriveItemProvider.
EXPECT().
GetShares(mock.Anything, mock.Anything, mock.Anything).
GetSharesForResource(mock.Anything, mock.Anything, mock.Anything).
Return(nil, errors.New("some error")).
Once()
@@ -907,7 +907,7 @@ var _ = Describe("DrivesDriveItemApi", func() {
drivesDriveItemProvider.
EXPECT().
GetShares(mock.Anything, mock.Anything, mock.Anything).
GetSharesForResource(mock.Anything, mock.Anything, mock.Anything).
Return([]*collaborationv1beta1.ReceivedShare{share}, nil).
Once()
})
@@ -967,7 +967,7 @@ var _ = Describe("DrivesDriveItemApi", func() {
drivesDriveItemProvider.
EXPECT().
GetShares(mock.Anything, mock.Anything, mock.Anything).
GetSharesForResource(mock.Anything, mock.Anything, mock.Anything).
Return([]*collaborationv1beta1.ReceivedShare{share}, nil).
Once()