mirror of
https://github.com/kopia/kopia.git
synced 2026-05-11 00:04:46 -04:00
* test symlink infinite loop * remove spurious error wrap * cleanup error messages * remove unneeded intermediate vars * check error in loop in fs.GetAllEntries While cur is expected to be `nil` when there's an error, this makes the check explicit. Ref: - #2037 - #4190
32 lines
613 B
Go
32 lines
613 B
Go
package ignorefs
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/kopia/kopia/fs"
|
|
"github.com/kopia/kopia/internal/mockfs"
|
|
"github.com/kopia/kopia/internal/testlogging"
|
|
)
|
|
|
|
func TestNoInfiniteResolveLink(t *testing.T) {
|
|
root := mockfs.NewDirectory()
|
|
|
|
root.AddSymlink("a", "./b", 0)
|
|
root.AddSymlink("b", "./c", 0)
|
|
root.AddSymlink("c", "./a", 0)
|
|
|
|
ctx := testlogging.Context(t)
|
|
e, err := root.Child(ctx, "b")
|
|
require.NoError(t, err)
|
|
|
|
s, ok := e.(fs.Symlink)
|
|
require.True(t, ok)
|
|
|
|
f, err := resolveSymlink(ctx, s)
|
|
|
|
require.ErrorIs(t, err, errTooManySymlinks)
|
|
require.Nil(t, f)
|
|
}
|