digest: better test coverage
Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
6a74c94bf8
commit
ecb2ee3824
4 changed files with 116 additions and 11 deletions
|
@ -1,8 +1,6 @@
|
|||
package digest
|
||||
|
||||
import (
|
||||
_ "crypto/sha256"
|
||||
_ "crypto/sha512"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -28,6 +26,11 @@ func TestParseDigest(t *testing.T) {
|
|||
input: "sha256:",
|
||||
err: ErrDigestInvalidFormat,
|
||||
},
|
||||
{
|
||||
// empty hex
|
||||
input: ":",
|
||||
err: ErrDigestInvalidFormat,
|
||||
},
|
||||
{
|
||||
// just hex
|
||||
input: "d41d8cd98f00b204e9800998ecf8427e",
|
||||
|
@ -80,5 +83,10 @@ func TestParseDigest(t *testing.T) {
|
|||
if newParsed != digest {
|
||||
t.Fatalf("expected equal: %q != %q", newParsed, digest)
|
||||
}
|
||||
|
||||
newFromHex := NewDigestFromHex(newParsed.Algorithm().String(), newParsed.Hex())
|
||||
if newFromHex != digest {
|
||||
t.Fatalf("%v != %v", newFromHex, digest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue