Merge pull request #251 from jlhawn/digest_pkg_cleanup

digest: Minor refactoring
This commit is contained in:
Derek McGowan 2015-03-10 19:17:37 -07:00
commit 4ae9583092
4 changed files with 28 additions and 6 deletions

View File

@ -236,7 +236,10 @@ func TestLayerAPI(t *testing.T) {
})
// Verify the body
verifier := digest.NewDigestVerifier(layerDigest)
verifier, err := digest.NewDigestVerifier(layerDigest)
if err != nil {
t.Fatalf("unexpected error getting digest verifier: %s", err)
}
io.Copy(verifier, resp.Body)
if !verifier.Verified() {

View File

@ -41,7 +41,11 @@ func TestSimpleRead(t *testing.T) {
t.Fatalf("error allocating file reader: %v", err)
}
verifier := digest.NewDigestVerifier(dgst)
verifier, err := digest.NewDigestVerifier(dgst)
if err != nil {
t.Fatalf("error getting digest verifier: %s", err)
}
io.Copy(verifier, fr)
if !verifier.Verified() {

View File

@ -55,7 +55,11 @@ func TestSimpleWrite(t *testing.T) {
}
defer fr.Close()
verifier := digest.NewDigestVerifier(dgst)
verifier, err := digest.NewDigestVerifier(dgst)
if err != nil {
t.Fatalf("unexpected error getting digest verifier: %s", err)
}
io.Copy(verifier, fr)
if !verifier.Verified() {
@ -94,7 +98,11 @@ func TestSimpleWrite(t *testing.T) {
}
defer fr.Close()
verifier = digest.NewDigestVerifier(doubledgst)
verifier, err = digest.NewDigestVerifier(doubledgst)
if err != nil {
t.Fatalf("unexpected error getting digest verifier: %s", err)
}
io.Copy(verifier, fr)
if !verifier.Verified() {
@ -141,7 +149,11 @@ func TestSimpleWrite(t *testing.T) {
}
defer fr.Close()
verifier = digest.NewDigestVerifier(doubledgst)
verifier, err = digest.NewDigestVerifier(doubledgst)
if err != nil {
t.Fatalf("unexpected error getting digest verifier: %s", err)
}
io.Copy(verifier, fr)
if !verifier.Verified() {

View File

@ -85,7 +85,10 @@ func (luc *layerUploadController) Cancel() error {
// validateLayer checks the layer data against the digest, returning an error
// if it does not match. The canonical digest is returned.
func (luc *layerUploadController) validateLayer(dgst digest.Digest) (digest.Digest, error) {
digestVerifier := digest.NewDigestVerifier(dgst)
digestVerifier, err := digest.NewDigestVerifier(dgst)
if err != nil {
return "", err
}
// TODO(stevvooe): Store resumable hash calculations in upload directory
// in driver. Something like a file at path <uuid>/resumablehash/<offest>