filesystem_test.go 1014 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (C) 2017 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. "path/filepath"
  9. "testing"
  10. )
  11. func TestIsInternal(t *testing.T) {
  12. cases := []struct {
  13. file string
  14. internal bool
  15. }{
  16. {".stfolder", true},
  17. {".stignore", true},
  18. {".stversions", true},
  19. {".stfolder/foo", true},
  20. {".stignore/foo", true},
  21. {".stversions/foo", true},
  22. {".stfolderfoo", false},
  23. {".stignorefoo", false},
  24. {".stversionsfoo", false},
  25. {"foo.stfolder", false},
  26. {"foo.stignore", false},
  27. {"foo.stversions", false},
  28. {"foo/.stfolder", false},
  29. {"foo/.stignore", false},
  30. {"foo/.stversions", false},
  31. }
  32. for _, tc := range cases {
  33. res := IsInternal(filepath.FromSlash(tc.file))
  34. if res != tc.internal {
  35. t.Errorf("Unexpected result: IsInteral(%q): %v should be %v", tc.file, res, tc.internal)
  36. }
  37. }
  38. }