hash: allow runtime configuration of supported hashes for testing

This commit is contained in:
Nick Craig-Wood 2023-11-23 19:56:13 +00:00
parent a259226eb2
commit 251a8e3c39
1 changed files with 10 additions and 0 deletions

View File

@ -55,6 +55,16 @@ func RegisterHash(name, alias string, width int, newFunc func() hash.Hash) Type
return hashType
}
// SupportOnly makes the hash package only support the types passed
// in. Used for testing.
//
// It returns the previously supported types.
func SupportOnly(new []Type) (old []Type) {
old = supported
supported = new
return old
}
// ErrUnsupported should be returned by filesystem,
// if it is requested to deliver an unsupported hash type.
var ErrUnsupported = errors.New("hash type not supported")