fs/hash: align hashsum names and update documentation (#5339)
- Unify all hash names as lowercase alphanumerics without punctuation. - Legacy names continue to work but disappear from docs, they can be depreciated or dropped later. - Make rclone hashsum print supported hash list in case of wrong spelling. - Update documentation. Fixes #5071 Fixes #4841
This commit is contained in:
parent
07f2f3a62e
commit
5b6f637461
10 changed files with 122 additions and 82 deletions
|
@ -156,16 +156,53 @@ func TestHashStreamTypes(t *testing.T) {
|
|||
|
||||
func TestHashSetStringer(t *testing.T) {
|
||||
h := hash.NewHashSet(hash.SHA1, hash.MD5)
|
||||
assert.Equal(t, h.String(), "[MD5, SHA-1]")
|
||||
assert.Equal(t, "[md5, sha1]", h.String())
|
||||
h = hash.NewHashSet(hash.SHA1)
|
||||
assert.Equal(t, h.String(), "[SHA-1]")
|
||||
assert.Equal(t, "[sha1]", h.String())
|
||||
h = hash.NewHashSet()
|
||||
assert.Equal(t, h.String(), "[]")
|
||||
assert.Equal(t, "[]", h.String())
|
||||
}
|
||||
|
||||
func TestHashStringer(t *testing.T) {
|
||||
h := hash.MD5
|
||||
assert.Equal(t, h.String(), "MD5")
|
||||
assert.Equal(t, "md5", h.String())
|
||||
h = hash.SHA1
|
||||
assert.Equal(t, "sha1", h.String())
|
||||
h = hash.None
|
||||
assert.Equal(t, h.String(), "None")
|
||||
assert.Equal(t, "none", h.String())
|
||||
}
|
||||
|
||||
func TestHashSetter(t *testing.T) {
|
||||
var ht hash.Type
|
||||
|
||||
assert.NoError(t, ht.Set("none"))
|
||||
assert.Equal(t, hash.None, ht)
|
||||
assert.NoError(t, ht.Set("None"))
|
||||
assert.Equal(t, hash.None, ht)
|
||||
|
||||
assert.NoError(t, ht.Set("md5"))
|
||||
assert.Equal(t, hash.MD5, ht)
|
||||
assert.NoError(t, ht.Set("MD5"))
|
||||
assert.Equal(t, hash.MD5, ht)
|
||||
|
||||
assert.NoError(t, ht.Set("sha1"))
|
||||
assert.Equal(t, hash.SHA1, ht)
|
||||
assert.NoError(t, ht.Set("SHA-1"))
|
||||
assert.Equal(t, hash.SHA1, ht)
|
||||
|
||||
assert.NoError(t, ht.Set("SHA1"))
|
||||
assert.Equal(t, hash.SHA1, ht)
|
||||
assert.NoError(t, ht.Set("Sha1"))
|
||||
assert.Equal(t, hash.SHA1, ht)
|
||||
assert.Error(t, ht.Set("Sha-1"))
|
||||
}
|
||||
|
||||
func TestHashTypeStability(t *testing.T) {
|
||||
assert.Equal(t, hash.Type(0), hash.None)
|
||||
assert.Equal(t, hash.Type(1), hash.MD5)
|
||||
assert.Equal(t, hash.Type(2), hash.SHA1)
|
||||
|
||||
assert.True(t, hash.Supported().Contains(hash.MD5))
|
||||
assert.True(t, hash.Supported().Contains(hash.SHA1))
|
||||
assert.False(t, hash.Supported().Contains(hash.None))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue