Skip to content

Commit 74d7b17

Browse files
Update tests to use hashers
1 parent 263d517 commit 74d7b17

24 files changed

+813
-707
lines changed

cache/disk/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ go_test(
4343
"//cache:go_default_library",
4444
"//cache/disk/casblob:go_default_library",
4545
"//cache/disk/zstdimpl:go_default_library",
46+
"//cache/hashing:go_default_library",
4647
"//cache/httpproxy:go_default_library",
4748
"//genproto/build/bazel/remote/execution/v2:go_default_library",
4849
"//utils:go_default_library",

cache/disk/casblob/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ go_test(
1717
deps = [
1818
":go_default_library",
1919
"//cache/disk/zstdimpl:go_default_library",
20+
"//cache/hashing:go_default_library",
2021
"//utils:go_default_library",
2122
],
2223
)

cache/disk/casblob/casblob_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package casblob_test
22

33
import (
44
"bytes"
5-
"crypto/sha256"
6-
"encoding/hex"
75
"fmt"
86
"io"
97
"os"
@@ -12,6 +10,7 @@ import (
1210

1311
"github.com/buchgr/bazel-remote/v2/cache/disk/casblob"
1412
"github.com/buchgr/bazel-remote/v2/cache/disk/zstdimpl"
13+
"github.com/buchgr/bazel-remote/v2/cache/hashing"
1514
testutils "github.com/buchgr/bazel-remote/v2/utils"
1615
)
1716

@@ -35,7 +34,7 @@ func TestZstdFromLegacy(t *testing.T) {
3534
t.Fatal(err)
3635
}
3736

38-
data, hash := testutils.RandomDataAndHash(int64(size))
37+
data, hash := testutils.RandomDataAndHash(int64(size), hashing.DefaultHasher)
3938
dir := testutils.TempDir(t)
4039
filename := fmt.Sprintf("%s/%s", dir, hash)
4140
file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0664)
@@ -73,8 +72,7 @@ func TestZstdFromLegacy(t *testing.T) {
7372
t.Fatalf("Unexpected buf size %d, expected %d", buf.Len(), size)
7473
}
7574

76-
h := sha256.Sum256(data)
77-
hs := hex.EncodeToString(h[:])
75+
hs := hashing.DefaultHasher.Hash(data)
7876
if hs != hash {
7977
t.Fatalf("Unexpected content sha %s, expected %s", hs, hash)
8078
}

0 commit comments

Comments
 (0)