mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
cmd/hashsum: dont put ERROR or UNSUPPORTED in output
This commit is contained in:
@@ -43,6 +43,7 @@ import (
|
||||
"github.com/rclone/rclone/fs/hash"
|
||||
"github.com/rclone/rclone/fs/operations"
|
||||
"github.com/rclone/rclone/fstest"
|
||||
"github.com/rclone/rclone/fstest/fstests"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -330,6 +331,33 @@ func TestHashSums(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHashSumsWithErrors(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
memFs, err := fs.NewFs(ctx, ":memory:")
|
||||
require.NoError(t, err)
|
||||
|
||||
// Make a test file
|
||||
content := "-"
|
||||
item1 := fstest.NewItem("file1", content, t1)
|
||||
_, _ = fstests.PutTestContents(ctx, t, memFs, &item1, content, true)
|
||||
|
||||
// MemoryFS supports MD5
|
||||
buf := &bytes.Buffer{}
|
||||
err = operations.HashLister(ctx, hash.MD5, false, false, memFs, buf)
|
||||
require.NoError(t, err)
|
||||
assert.Contains(t, buf.String(), "336d5ebc5436534e61d16e63ddfca327 file1\n")
|
||||
|
||||
// MemoryFS can't do SHA1, but UNSUPPORTED must not appear in the output
|
||||
buf.Reset()
|
||||
err = operations.HashLister(ctx, hash.SHA1, false, false, memFs, buf)
|
||||
require.NoError(t, err)
|
||||
assert.NotContains(t, buf.String(), " UNSUPPORTED ")
|
||||
|
||||
// ERROR must not appear in the output either
|
||||
assert.NotContains(t, buf.String(), " ERROR ")
|
||||
// TODO mock an unreadable file
|
||||
}
|
||||
|
||||
func TestSuffixName(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx, ci := fs.AddConfig(ctx)
|
||||
|
||||
Reference in New Issue
Block a user