Skip to content

Commit 4a9f8ac

Browse files
mortenmjEdSchouten
authored andcommitted
Update uses of bb_digest
1 parent f7cc5f9 commit 4a9f8ac

File tree

7 files changed

+16
-10
lines changed

7 files changed

+16
-10
lines changed

pkg/fetch/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ go_test(
6060
"@com_github_buildbarn_bb_storage//pkg/blobstore/buffer",
6161
"@com_github_buildbarn_bb_storage//pkg/digest",
6262
"@com_github_buildbarn_bb_storage//pkg/testutil",
63+
"@com_github_buildbarn_bb_storage//pkg/util",
6364
"@com_github_golang_mock//gomock",
6465
"@com_github_stretchr_testify//require",
6566
"@org_golang_google_genproto_googleapis_rpc//status",

pkg/fetch/authorizing_fetcher_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/buildbarn/bb-remote-asset/internal/mock"
1010
"github.com/buildbarn/bb-remote-asset/pkg/fetch"
1111
bb_digest "github.com/buildbarn/bb-storage/pkg/digest"
12+
"github.com/buildbarn/bb-storage/pkg/util"
1213
"github.com/golang/mock/gomock"
1314
"github.com/stretchr/testify/require"
1415
"google.golang.org/grpc/codes"
@@ -22,7 +23,7 @@ func TestFetchBlobAuthorization(t *testing.T) {
2223
authorizer := mock.NewMockAuthorizer(ctrl)
2324
af := fetch.NewAuthorizingFetcher(baseFetcher, authorizer)
2425

25-
instanceName := bb_digest.MustNewInstanceName("gondor")
26+
instanceName := util.Must(bb_digest.NewInstanceName("gondor"))
2627
instanceSlice := []bb_digest.InstanceName{instanceName}
2728

2829
uri := "source.test"
@@ -66,7 +67,7 @@ func TestFetchDirectoryAuthorization(t *testing.T) {
6667
authorizer := mock.NewMockAuthorizer(ctrl)
6768
af := fetch.NewAuthorizingFetcher(baseFetcher, authorizer)
6869

69-
instanceName := bb_digest.MustNewInstanceName("gondor")
70+
instanceName := util.Must(bb_digest.NewInstanceName("gondor"))
7071
instanceSlice := []bb_digest.InstanceName{instanceName}
7172

7273
uri := "source.test"

pkg/fetch/http_fetcher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func getChecksumSri(qualifiers []*remoteasset.Qualifier) (string, bb_digest.Func
212212
// Convert to a proper digest function.
213213
// Note: The Instance name doesn't matter here, this function is used only
214214
// to give us a convenient API when actually checking the checksum.
215-
instance := bb_digest.MustNewInstanceName("")
215+
instance := util.Must(bb_digest.NewInstanceName(""))
216216
checksumFunction, err := instance.GetDigestFunction(digestFunctionEnum, len(expectedDigest))
217217
if err != nil {
218218
return "", bb_digest.Function{}, status.Errorf(codes.InvalidArgument, "Failed to get checksum function for checksum.sri: %s", err.Error())

pkg/fetch/http_fetcher_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/buildbarn/bb-remote-asset/pkg/qualifier"
1515
"github.com/buildbarn/bb-storage/pkg/digest"
1616
"github.com/buildbarn/bb-storage/pkg/testutil"
17+
"github.com/buildbarn/bb-storage/pkg/util"
1718

1819
remoteasset "github.com/bazelbuild/remote-apis/build/bazel/remote/asset/v1"
1920
remoteexecution "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2"
@@ -119,7 +120,7 @@ func TestHTTPFetcherFetchBlobSuccessSha256tree(t *testing.T) {
119120
func testHTTPFetcherFetchBlobSuccessWithHasher(t *testing.T, digestFunctionEnum remoteexecution.DigestFunction_Value) {
120121
ctrl, ctx := gomock.WithContext(context.Background(), t)
121122

122-
instance := digest.MustNewInstanceName(InstanceName)
123+
instance := util.Must(digest.NewInstanceName(InstanceName))
123124
digestFunction, err := instance.GetDigestFunction(digestFunctionEnum, 0)
124125
require.NoError(t, err)
125126
digestGenerator := digestFunction.NewGenerator(int64(len(TestData)))
@@ -177,7 +178,7 @@ func testHTTPFetcherFetchBlobSuccessWithHasher(t *testing.T, digestFunctionEnum
177178
func TestHTTPFetcherFetchBlob(t *testing.T) {
178179
ctrl, ctx := gomock.WithContext(context.Background(), t)
179180

180-
instance := digest.MustNewInstanceName(InstanceName)
181+
instance := util.Must(digest.NewInstanceName(InstanceName))
181182
digestFunction, err := instance.GetDigestFunction(remoteexecution.DigestFunction_SHA256, 0)
182183
require.NoError(t, err)
183184
digestGenerator := digestFunction.NewGenerator(int64(len(TestData)))

pkg/storage/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ go_test(
4646
"@bazel_remote_apis//build/bazel/remote/execution/v2:remote_execution_go_proto",
4747
"@com_github_buildbarn_bb_storage//pkg/blobstore/buffer",
4848
"@com_github_buildbarn_bb_storage//pkg/digest",
49+
"@com_github_buildbarn_bb_storage//pkg/util",
4950
"@com_github_golang_mock//gomock",
5051
"@com_github_stretchr_testify//require",
5152
"@org_golang_google_grpc//codes",

pkg/storage/action_cache_asset_store_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/buildbarn/bb-remote-asset/pkg/storage"
1414
"github.com/buildbarn/bb-storage/pkg/blobstore/buffer"
1515
"github.com/buildbarn/bb-storage/pkg/digest"
16+
"github.com/buildbarn/bb-storage/pkg/util"
1617
"github.com/golang/mock/gomock"
1718
"github.com/stretchr/testify/require"
1819
"google.golang.org/protobuf/proto"
@@ -34,7 +35,7 @@ func bbDigest(d *remoteexecution.Digest) digest.Digest {
3435
func TestActionCacheAssetStorePutBlob(t *testing.T) {
3536
ctrl, ctx := gomock.WithContext(context.Background(), t)
3637

37-
instanceName := digest.MustNewInstanceName("")
38+
instanceName := util.Must(digest.NewInstanceName(""))
3839
digestFunction, err := instanceName.GetDigestFunction(remoteexecution.DigestFunction_SHA256, 0)
3940
require.NoError(t, err)
4041

@@ -499,7 +500,7 @@ func TestActionCacheAssetStoreRoundTripWithSpecialQualifiers(t *testing.T) {
499500
func TestActionCacheAssetStoreGetBlob(t *testing.T) {
500501
ctrl, ctx := gomock.WithContext(context.Background(), t)
501502

502-
instanceName := digest.MustNewInstanceName("")
503+
instanceName := util.Must(digest.NewInstanceName(""))
503504
digestFunction, err := instanceName.GetDigestFunction(remoteexecution.DigestFunction_SHA256, 0)
504505
require.NoError(t, err)
505506

@@ -542,7 +543,7 @@ func TestActionCacheAssetStoreGetBlob(t *testing.T) {
542543
func TestActionCacheAssetStoreGetDirectory(t *testing.T) {
543544
ctrl, ctx := gomock.WithContext(context.Background(), t)
544545

545-
instanceName := digest.MustNewInstanceName("")
546+
instanceName := util.Must(digest.NewInstanceName(""))
546547
digestFunction, err := instanceName.GetDigestFunction(remoteexecution.DigestFunction_SHA256, 0)
547548
require.NoError(t, err)
548549

pkg/storage/authorizing_asset_store_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/buildbarn/bb-remote-asset/internal/mock"
1010
"github.com/buildbarn/bb-remote-asset/pkg/storage"
1111
bb_digest "github.com/buildbarn/bb-storage/pkg/digest"
12+
"github.com/buildbarn/bb-storage/pkg/util"
1213
"github.com/golang/mock/gomock"
1314
"github.com/stretchr/testify/require"
1415
"google.golang.org/grpc/codes"
@@ -19,7 +20,7 @@ import (
1920
func TestAuthorizingBlobAccessGet(t *testing.T) {
2021
ctrl, ctx := gomock.WithContext(context.Background(), t)
2122

22-
instanceName := bb_digest.MustNewInstanceName("rohan")
23+
instanceName := util.Must(bb_digest.NewInstanceName("rohan"))
2324
instanceSlice := []bb_digest.InstanceName{instanceName}
2425
digestFunction, err := instanceName.GetDigestFunction(remoteexecution.DigestFunction_SHA256, 0)
2526
require.NoError(t, err)
@@ -54,7 +55,7 @@ func TestAuthorizingBlobAccessGet(t *testing.T) {
5455
func TestAuthorizingBlobAccessPut(t *testing.T) {
5556
ctrl, ctx := gomock.WithContext(context.Background(), t)
5657

57-
instanceName := bb_digest.MustNewInstanceName("rohan")
58+
instanceName := util.Must(bb_digest.NewInstanceName("rohan"))
5859
instanceSlice := []bb_digest.InstanceName{instanceName}
5960
digestFunction, err := instanceName.GetDigestFunction(remoteexecution.DigestFunction_SHA256, 0)
6061
require.NoError(t, err)

0 commit comments

Comments
 (0)