Skip to content

Commit

Permalink
refactor(service/share): GetSharesByNamespace - no error if namespace…
Browse files Browse the repository at this point in the history
… not found

* This is simillar to changes introduced in #661 in IPLD package.
* Test was broken - `Error` checks for error and prints a message
  (there's `ErrorContains` for string comparison)
  • Loading branch information
tzdybal committed May 6, 2022
1 parent 3035f66 commit 0d58b3a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion service/share/share.go
Expand Up @@ -159,7 +159,7 @@ func (s *service) GetSharesByNamespace(ctx context.Context, root *Root, nID name
}
}
if len(rowRootCIDs) == 0 {
return nil, format.ErrNotFound
return nil, nil
}

errGroup, ctx := errgroup.WithContext(ctx)
Expand Down
4 changes: 2 additions & 2 deletions service/share/share_test.go
Expand Up @@ -108,13 +108,13 @@ func TestGetShares(t *testing.T) {
require.NoError(t, err)
}

func TestService_GetSharesByNamespaceNotFoundInRange(t *testing.T) {
func TestService_GetSharesByNamespaceNotFound(t *testing.T) {
serv, root := RandLightServiceWithSquare(t, 1)
root.RowsRoots = nil

shares, err := serv.GetSharesByNamespace(context.Background(), root, []byte(""))
assert.Len(t, shares, 0)
require.Error(t, err, "namespaceID not found in range")
assert.NoError(t, err)
}

func BenchmarkService_GetSharesByNamespace(b *testing.B) {
Expand Down

0 comments on commit 0d58b3a

Please sign in to comment.