eee6cad2cf
The change relies on a refactor of the upstream resumable sha256/sha512 package that opts to register implementations with the standard library. This allows the resumable support to be detected where it matters, avoiding unnecessary and complex code. It also ensures that consumers of the digest package don't need to depend on the forked sha implementations. We also get an optimization with this change. If the size of data written to a digester is the same as the file size, we check to see if the digest has been verified. This works if the blob is written and committed in a single request. Signed-off-by: Stephen J Day <stephen.day@docker.com>
22 lines
513 B
Go
22 lines
513 B
Go
// +build !noresumabledigest
|
|
|
|
package digest
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stevvooe/resumable"
|
|
_ "github.com/stevvooe/resumable/sha256"
|
|
)
|
|
|
|
// TestResumableDetection just ensures that the resumable capability of a hash
|
|
// is exposed through the digester type, which is just a hash plus a Digest
|
|
// method.
|
|
func TestResumableDetection(t *testing.T) {
|
|
d := NewCanonicalDigester()
|
|
|
|
if _, ok := d.Hash().(resumable.Hash); !ok {
|
|
t.Fatalf("expected digester to implement resumable: %#v, %v", d, d.Hash())
|
|
}
|
|
}
|