Skip to content

Commit 01e3f4b

Browse files
committed
fix: merge conflicts
Signed-off-by: Ramkumar Chinchani <[email protected]>
1 parent 56db9bb commit 01e3f4b

File tree

5 files changed

+84
-19
lines changed

5 files changed

+84
-19
lines changed

blake3.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ import (
2222
const (
2323
// Blake3 is the blake3 algorithm with the default 256-bit output size
2424
Blake3 Algorithm = "blake3"
25-
26-
// BLAKE3 is deprecated. Use the symbol "Blake3" instead.
27-
BLAKE3 = Blake3
2825
)
2926

3027
func init() {

digest_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ func TestParseDigest(t *testing.T) {
4141
{
4242
Input: "blake3:af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262",
4343
Algorithm: "blake3",
44+
Encoded: "af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262",
45+
},
4446
{
4547
// empty
4648
Input: "",
@@ -88,11 +90,11 @@ func TestParseDigest(t *testing.T) {
8890
},
8991
{
9092
// too short (from different algorithm)
91-
input: "blake3:abcdef0123456789abcdef0123456789abcdef01234",
92-
Err: diest.ErrDigestInvalidLength,
93+
Input: "blake3:abcdef0123456789abcdef0123456789abcdef01234",
94+
Err: digest.ErrDigestInvalidLength,
9395
},
9496
{
95-
input: "foo:d41d8cd98f00b204e9800998ecf8427e",
97+
Input: "foo:d41d8cd98f00b204e9800998ecf8427e",
9698
Err: digest.ErrDigestUnsupported,
9799
},
98100
{

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/opencontainers/go-digest
22

3-
go 1.18
3+
go 1.23
44

55
require github.com/zeebo/blake3 v0.2.4
66

go.sum

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
2-
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
3-
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
1+
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
2+
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
43
github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY=
54
github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
6-
github.com/zeebo/blake3 v0.2.2 h1:ddH9fUIlef5r+pqvJShGgSXFd6c7k54eQXZ48hNjotQ=
7-
github.com/zeebo/blake3 v0.2.2/go.mod h1:TSQ0KjMH+pht+bRyvVooJ1rBpvvngSGaPISafq9MxJk=
8-
github.com/zeebo/blake3 v0.2.3 h1:TFoLXsjeXqRNFxSbk35Dk4YtszE/MQQGK10BH4ptoTg=
9-
github.com/zeebo/blake3 v0.2.3/go.mod h1:mjJjZpnsyIVtVgTOSpJ9vmRE4wgDeyt2HU3qXvvKCaQ=
5+
github.com/zeebo/blake3 v0.2.4 h1:KYQPkhpRtcqh0ssGYcKLG1JYvddkEA8QwCM/yBqhaZI=
6+
github.com/zeebo/blake3 v0.2.4/go.mod h1:7eeQ6d2iXWRGF6npfaxl2CU+xy2Fjo2gxeyZGCRUjcE=
107
github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo=
118
github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
12-
golang.org/x/sys v0.0.0-20201014080544-cc95f250f6bc h1:HVFDs9bKvTxP6bh1Rj9MCSo+UmafQtI8ZWDPVwVk9g4=
13-
golang.org/x/sys v0.0.0-20201014080544-cc95f250f6bc/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14-
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
15-
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
16-
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
9+
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
10+
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=

testdigest/testdigest.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright 2021 OCI Contributors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Package testdigest is a separate package, because it has some testing
16+
// utilities that may be useful to other internal Algorithm implementors.
17+
//
18+
// It is not a stable interface and not meant for consumption outside of
19+
// digest developers.
20+
package testdigest
21+
22+
import (
23+
"errors"
24+
"testing"
25+
26+
"github.com/opencontainers/go-digest"
27+
)
28+
29+
type TestCase struct {
30+
// Input the formal format of the hash, for example sha256:e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b
31+
Input string
32+
// If err is non-nil, then the parsing of Input is expected to return this error
33+
Err error
34+
// Algorithm should be an available or registered algorithm
35+
Algorithm digest.Algorithm
36+
// Encoded is the the encoded portion of the digest to expect, for example e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b
37+
Encoded string
38+
}
39+
40+
func RunTestCase(t *testing.T, testcase TestCase) {
41+
dgst, err := digest.Parse(testcase.Input)
42+
if !errors.Is(err, testcase.Err) {
43+
t.Fatalf("error differed from expected while parsing %q: %v != %v", testcase.Input, err, testcase.Err)
44+
}
45+
46+
if testcase.Err != nil {
47+
return
48+
}
49+
50+
if dgst.Algorithm() != testcase.Algorithm {
51+
t.Fatalf("incorrect Algorithm for parsed digest: %q != %q", dgst.Algorithm(), testcase.Algorithm)
52+
}
53+
54+
if dgst.Encoded() != testcase.Encoded {
55+
t.Fatalf("incorrect hex for parsed digest: %q != %q", dgst.Encoded(), testcase.Encoded)
56+
}
57+
58+
// Parse string return value and check equality
59+
newParsed, err := digest.Parse(dgst.String())
60+
if err != nil {
61+
t.Fatalf("unexpected error parsing Input %q: %v", testcase.Input, err)
62+
}
63+
64+
if newParsed != dgst {
65+
t.Fatalf("expected equal: %q != %q", newParsed, dgst)
66+
}
67+
68+
newFromHex := digest.NewDigestFromEncoded(newParsed.Algorithm(), newParsed.Encoded())
69+
if newFromHex != dgst {
70+
t.Fatalf("%v != %v", newFromHex, dgst)
71+
}
72+
}

0 commit comments

Comments
 (0)