MCPcopy Index your code
hub / github.com/syncthing/syncthing / TestNewBasicFilesystem

Function TestNewBasicFilesystem

lib/fs/basicfs_test.go:510–545  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

508}
509
510func TestNewBasicFilesystem(t *testing.T) {
511 if build.IsWindows {
512 t.Skip("non-windows root paths")
513 }
514
515 currentDir, err := filepath.Abs(".")
516 if err != nil {
517 t.Fatal(err)
518 }
519 testCases := []struct {
520 input string
521 expectedRoot string
522 expectedURI string
523 }{
524 {"/foo/bar/baz", "/foo/bar/baz", "/foo/bar/baz"},
525 {"/foo/bar/baz/", "/foo/bar/baz", "/foo/bar/baz"},
526 {"", currentDir, currentDir},
527 {".", currentDir, currentDir},
528 {"/", "/", "/"},
529 }
530
531 for _, testCase := range testCases {
532 fs := newBasicFilesystem(testCase.input)
533 if fs.root != testCase.expectedRoot {
534 t.Errorf("root %q != %q", fs.root, testCase.expectedRoot)
535 }
536 if fs.URI() != testCase.expectedURI {
537 t.Errorf("uri %q != %q", fs.URI(), testCase.expectedURI)
538 }
539 }
540
541 fs := newBasicFilesystem("relative/path")
542 if fs.root == "relative/path" || !strings.HasPrefix(fs.root, string(PathSeparator)) {
543 t.Errorf(`newBasicFilesystem("relative/path").root == %q, expected absolutification`, fs.root)
544 }
545}
546
547func TestRel(t *testing.T) {
548 testCases := []struct {

Callers

nothing calls this directly

Calls 3

newBasicFilesystemFunction · 0.85
FatalMethod · 0.80
URIMethod · 0.65

Tested by

no test coverage detected