1
0
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:
Sebastiaan van Stijn
2023-08-01 14:22:13 +02:00
parent f94d70dcad
commit 84af967803

View File

@ -83,6 +83,7 @@ func TestFroms(t *testing.T) {
}
for alg := range algorithms {
t.Run(string(alg), func(t *testing.T) {
h := alg.Hash()
h.Write(p)
expected := Digest(fmt.Sprintf("%s:%x", alg, h.Sum(nil)))
@ -112,9 +113,10 @@ func TestFroms(t *testing.T) {
}
for _, dgst := range dgsts {
if dgst != expected {
t.Fatalf("unexpected digest %v != %v", dgst, expected)
t.Errorf("unexpected digest %v != %v", dgst, expected)
}
}
})
}
}