walkfs_test.go 989 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (C) 2019 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package fs
  7. import (
  8. "runtime"
  9. "testing"
  10. )
  11. func testWalkSkipSymlink(t *testing.T, fsType FilesystemType, uri string) {
  12. if runtime.GOOS == "windows" {
  13. t.Skip("Symlinks on windows")
  14. }
  15. fs := NewFilesystem(fsType, uri)
  16. if err := fs.MkdirAll("target/foo", 0755); err != nil {
  17. t.Fatal(err)
  18. }
  19. if err := fs.Mkdir("towalk", 0755); err != nil {
  20. t.Fatal(err)
  21. }
  22. if err := fs.CreateSymlink("target", "towalk/symlink"); err != nil {
  23. t.Fatal(err)
  24. }
  25. if err := fs.Walk("towalk", func(path string, info FileInfo, err error) error {
  26. if err != nil {
  27. t.Fatal(err)
  28. }
  29. if info.Name() != "symlink" && info.Name() != "towalk" {
  30. t.Fatal("Walk unexpected file", info.Name())
  31. }
  32. return nil
  33. }); err != nil {
  34. t.Fatal(err)
  35. }
  36. }