You've already forked go-digest
mirror of
https://github.com/opencontainers/go-digest.git
synced 2025-07-30 00:21:10 +03:00
TestFroms: use sub-tests
Use sub-tests to not fail early if an algorithm fails. With this change: === RUN TestFroms === RUN TestFroms/sha256 === RUN TestFroms/sha384 === RUN TestFroms/sha512 --- PASS: TestFroms (0.02s) --- PASS: TestFroms/sha256 (0.01s) --- PASS: TestFroms/sha384 (0.00s) --- PASS: TestFroms/sha512 (0.00s) PASS Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -83,6 +83,7 @@ func TestFroms(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for alg := range algorithms {
|
for alg := range algorithms {
|
||||||
|
t.Run(string(alg), func(t *testing.T) {
|
||||||
h := alg.Hash()
|
h := alg.Hash()
|
||||||
h.Write(p)
|
h.Write(p)
|
||||||
expected := Digest(fmt.Sprintf("%s:%x", alg, h.Sum(nil)))
|
expected := Digest(fmt.Sprintf("%s:%x", alg, h.Sum(nil)))
|
||||||
@ -112,9 +113,10 @@ func TestFroms(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, dgst := range dgsts {
|
for _, dgst := range dgsts {
|
||||||
if dgst != expected {
|
if dgst != expected {
|
||||||
t.Fatalf("unexpected digest %v != %v", dgst, expected)
|
t.Errorf("unexpected digest %v != %v", dgst, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user