mirror of
https://github.com/restic/restic.git
synced 2026-08-06 13:43:18 +00:00
Apply go fix -any ./...
This commit is contained in:
@@ -1982,7 +1982,7 @@ func TestArchiverParent(t *testing.T) {
|
||||
t.Logf("testfs: %v", testFS)
|
||||
|
||||
// check that all files have been read exactly once
|
||||
TestWalkFiles(t, ".", test.src, func(filename string, item interface{}) error {
|
||||
TestWalkFiles(t, ".", test.src, func(filename string, item any) error {
|
||||
file, ok := item.(TestFile)
|
||||
if !ok {
|
||||
return nil
|
||||
|
||||
@@ -88,7 +88,7 @@ func (rc *rejectionCache) Store(dir string, rejected bool) {
|
||||
// non-nil if the filename component of excludeFileSpec is empty. If rc is
|
||||
// non-nil, it is going to be used in the RejectByNameFunc to expedite the evaluation
|
||||
// of a directory based on previous visits.
|
||||
func RejectIfPresent(excludeFileSpec string, warnf func(msg string, args ...interface{})) (RejectFunc, error) {
|
||||
func RejectIfPresent(excludeFileSpec string, warnf func(msg string, args ...any)) (RejectFunc, error) {
|
||||
if excludeFileSpec == "" {
|
||||
return nil, errors.New("name for exclusion tagfile is empty")
|
||||
}
|
||||
@@ -115,7 +115,7 @@ func RejectIfPresent(excludeFileSpec string, warnf func(msg string, args ...inte
|
||||
// tagfile which bears the name specified in tagFilename and starts with
|
||||
// header. If rc is non-nil, it is used to expedite the evaluation of a
|
||||
// directory based on previous visits.
|
||||
func isExcludedByFile(filename, tagFilename, header string, rc *rejectionCache, fs fs.FS, warnf func(msg string, args ...interface{})) bool {
|
||||
func isExcludedByFile(filename, tagFilename, header string, rc *rejectionCache, fs fs.FS, warnf func(msg string, args ...any)) bool {
|
||||
if tagFilename == "" {
|
||||
return false
|
||||
}
|
||||
@@ -136,7 +136,7 @@ func isExcludedByFile(filename, tagFilename, header string, rc *rejectionCache,
|
||||
return rejected
|
||||
}
|
||||
|
||||
func isDirExcludedByFile(dir, tagFilename, header string, fsInst fs.FS, warnf func(msg string, args ...interface{})) bool {
|
||||
func isDirExcludedByFile(dir, tagFilename, header string, fsInst fs.FS, warnf func(msg string, args ...any)) bool {
|
||||
tf := fsInst.Join(dir, tagFilename)
|
||||
_, err := fsInst.Lstat(tf)
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
@@ -318,7 +318,7 @@ func RejectBySize(maxSize int64) (RejectFunc, error) {
|
||||
}
|
||||
|
||||
// RejectCloudFiles returns a func which rejects files which are online-only cloud files
|
||||
func RejectCloudFiles(warnf func(msg string, args ...interface{})) (RejectFunc, error) {
|
||||
func RejectCloudFiles(warnf func(msg string, args ...any)) (RejectFunc, error) {
|
||||
return func(item string, fi *fs.ExtendedFileInfo, _ fs.FS) bool {
|
||||
recall, err := fi.RecallOnDataAccess()
|
||||
if err != nil {
|
||||
|
||||
@@ -49,7 +49,7 @@ func TestIsExcludedByFile(t *testing.T) {
|
||||
if tc.content == "" {
|
||||
h = ""
|
||||
}
|
||||
if got := isExcludedByFile(foo, tagFilename, h, newRejectionCache(), fs.NewLocal(), func(msg string, args ...interface{}) { t.Logf(msg, args...) }); tc.want != got {
|
||||
if got := isExcludedByFile(foo, tagFilename, h, newRejectionCache(), fs.NewLocal(), func(msg string, args ...any) { t.Logf(msg, args...) }); tc.want != got {
|
||||
t.Fatalf("expected %v, got %v", tc.want, got)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestSnapshot(t testing.TB, repo restic.Repository, path string, parent *res
|
||||
}
|
||||
|
||||
// TestDir describes a directory structure to create for a test.
|
||||
type TestDir map[string]interface{}
|
||||
type TestDir map[string]any
|
||||
|
||||
func (d TestDir) String() string {
|
||||
return "<Dir>"
|
||||
@@ -119,7 +119,7 @@ func TestCreateFiles(t testing.TB, target string, dir TestDir) {
|
||||
|
||||
// TestWalkFunc is used by TestWalkFiles to traverse the dir. When an error is
|
||||
// returned, traversal stops and the surrounding test is marked as failed.
|
||||
type TestWalkFunc func(path string, item interface{}) error
|
||||
type TestWalkFunc func(path string, item any) error
|
||||
|
||||
// TestWalkFiles runs fn for each file/directory in dir, the filename will be
|
||||
// constructed with target as the prefix. Symlinks on Windows are ignored.
|
||||
@@ -158,7 +158,7 @@ func TestEnsureFiles(t testing.TB, target string, dir TestDir) {
|
||||
pathsChecked := make(map[string]struct{})
|
||||
|
||||
// first, test that all items are there
|
||||
TestWalkFiles(t, target, dir, func(path string, item interface{}) error {
|
||||
TestWalkFiles(t, target, dir, func(path string, item any) error {
|
||||
fi, err := os.Lstat(path)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -28,30 +28,30 @@ func (t *MockT) Fail() {
|
||||
}
|
||||
|
||||
// Fatal is equivalent to Log followed by FailNow.
|
||||
func (t *MockT) Fatal(args ...interface{}) {
|
||||
func (t *MockT) Fatal(args ...any) {
|
||||
t.T.Logf("MockT Fatal called with %v", args)
|
||||
t.HasFailed = true
|
||||
}
|
||||
|
||||
// Fatalf is equivalent to Logf followed by FailNow.
|
||||
func (t *MockT) Fatalf(msg string, args ...interface{}) {
|
||||
func (t *MockT) Fatalf(msg string, args ...any) {
|
||||
t.T.Logf("MockT Fatal called: "+msg, args...)
|
||||
t.HasFailed = true
|
||||
}
|
||||
|
||||
// Error is equivalent to Log followed by Fail.
|
||||
func (t *MockT) Error(args ...interface{}) {
|
||||
func (t *MockT) Error(args ...any) {
|
||||
t.T.Logf("MockT Error called with %v", args)
|
||||
t.HasFailed = true
|
||||
}
|
||||
|
||||
// Errorf is equivalent to Logf followed by Fail.
|
||||
func (t *MockT) Errorf(msg string, args ...interface{}) {
|
||||
func (t *MockT) Errorf(msg string, args ...any) {
|
||||
t.T.Logf("MockT Error called: "+msg, args...)
|
||||
t.HasFailed = true
|
||||
}
|
||||
|
||||
func createFilesAt(t testing.TB, targetdir string, files map[string]interface{}) {
|
||||
func createFilesAt(t testing.TB, targetdir string, files map[string]any) {
|
||||
for name, item := range files {
|
||||
target := filepath.Join(targetdir, filepath.FromSlash(name))
|
||||
err := os.MkdirAll(filepath.Dir(target), 0700)
|
||||
@@ -77,7 +77,7 @@ func createFilesAt(t testing.TB, targetdir string, files map[string]interface{})
|
||||
func TestTestCreateFiles(t *testing.T) {
|
||||
var tests = []struct {
|
||||
dir TestDir
|
||||
files map[string]interface{}
|
||||
files map[string]any
|
||||
}{
|
||||
{
|
||||
dir: TestDir{
|
||||
@@ -91,7 +91,7 @@ func TestTestCreateFiles(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestFile{Content: "foo"},
|
||||
"subdir": TestDir{},
|
||||
"subdir/subfile": TestFile{Content: "bar"},
|
||||
@@ -196,7 +196,7 @@ func TestTestWalkFiles(t *testing.T) {
|
||||
got := make(map[string]string)
|
||||
|
||||
TestCreateFiles(t, tempdir, test.dir)
|
||||
TestWalkFiles(t, tempdir, test.dir, func(path string, item interface{}) error {
|
||||
TestWalkFiles(t, tempdir, test.dir, func(path string, item any) error {
|
||||
p, err := filepath.Rel(tempdir, path)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -216,11 +216,11 @@ func TestTestWalkFiles(t *testing.T) {
|
||||
func TestTestEnsureFiles(t *testing.T) {
|
||||
var tests = []struct {
|
||||
expectFailure bool
|
||||
files map[string]interface{}
|
||||
files map[string]any
|
||||
want TestDir
|
||||
}{
|
||||
{
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestFile{Content: "foo"},
|
||||
"subdir/subfile": TestFile{Content: "bar"},
|
||||
"x/y/link": TestSymlink{Target: filepath.Clean("../../foo")},
|
||||
@@ -239,7 +239,7 @@ func TestTestEnsureFiles(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestFile{Content: "foo"},
|
||||
},
|
||||
want: TestDir{
|
||||
@@ -251,7 +251,7 @@ func TestTestEnsureFiles(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestFile{Content: "foo"},
|
||||
"subdir/subfile": TestFile{Content: "bar"},
|
||||
},
|
||||
@@ -261,7 +261,7 @@ func TestTestEnsureFiles(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestFile{Content: "xxx"},
|
||||
},
|
||||
want: TestDir{
|
||||
@@ -270,7 +270,7 @@ func TestTestEnsureFiles(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestSymlink{Target: "/xxx"},
|
||||
},
|
||||
want: TestDir{
|
||||
@@ -279,7 +279,7 @@ func TestTestEnsureFiles(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestFile{Content: "foo"},
|
||||
},
|
||||
want: TestDir{
|
||||
@@ -288,7 +288,7 @@ func TestTestEnsureFiles(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestSymlink{Target: "xxx"},
|
||||
},
|
||||
want: TestDir{
|
||||
@@ -297,7 +297,7 @@ func TestTestEnsureFiles(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestDir{
|
||||
"foo": TestFile{Content: "foo"},
|
||||
},
|
||||
@@ -308,7 +308,7 @@ func TestTestEnsureFiles(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestFile{Content: "foo"},
|
||||
},
|
||||
want: TestDir{
|
||||
@@ -341,11 +341,11 @@ func TestTestEnsureFiles(t *testing.T) {
|
||||
func TestTestEnsureSnapshot(t *testing.T) {
|
||||
var tests = []struct {
|
||||
expectFailure bool
|
||||
files map[string]interface{}
|
||||
files map[string]any
|
||||
want TestDir
|
||||
}{
|
||||
{
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestFile{Content: "foo"},
|
||||
filepath.FromSlash("subdir/subfile"): TestFile{Content: "bar"},
|
||||
filepath.FromSlash("x/y/link"): TestSymlink{Target: filepath.FromSlash("../../foo")},
|
||||
@@ -366,7 +366,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestFile{Content: "foo"},
|
||||
},
|
||||
want: TestDir{
|
||||
@@ -377,7 +377,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestFile{Content: "foo"},
|
||||
"bar": TestFile{Content: "bar"},
|
||||
},
|
||||
@@ -389,7 +389,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestFile{Content: "foo"},
|
||||
},
|
||||
want: TestDir{
|
||||
@@ -401,7 +401,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestFile{Content: "foo"},
|
||||
},
|
||||
want: TestDir{
|
||||
@@ -414,7 +414,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestSymlink{Target: filepath.FromSlash("x/y/z")},
|
||||
},
|
||||
want: TestDir{
|
||||
@@ -425,7 +425,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestSymlink{Target: filepath.FromSlash("x/y/z")},
|
||||
},
|
||||
want: TestDir{
|
||||
@@ -436,7 +436,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
|
||||
},
|
||||
{
|
||||
expectFailure: true,
|
||||
files: map[string]interface{}{
|
||||
files: map[string]any{
|
||||
"foo": TestFile{Content: "foo"},
|
||||
},
|
||||
want: TestDir{
|
||||
|
||||
Reference in New Issue
Block a user