Skip to content

Commit

Permalink
refactor: rename GetShares to GetSharesForResource
Browse files Browse the repository at this point in the history
Rename this method to make more clear what it is about.
  • Loading branch information
JammingBen authored and rhafer committed May 14, 2024
1 parent 716e513 commit 779bf33
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
22 changes: 11 additions & 11 deletions services/graph/mocks/drives_drive_item_provider.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions services/graph/pkg/service/v0/api_drives_drive_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
26 changes: 13 additions & 13 deletions services/graph/pkg/service/v0/api_drives_drive_item_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand All @@ -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{
Expand All @@ -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))
})

Expand All @@ -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))
})

Expand All @@ -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))
})
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()
})
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 779bf33

Please sign in to comment.