MCPcopy
hub / github.com/syncthing/syncthing / testFakeFSOpenFile

Function testFakeFSOpenFile

lib/fs/fakefs_test.go:612–642  ·  view source on GitHub ↗
(t *testing.T, fs Filesystem)

Source from the content-addressed store, hash-verified

610}
611
612func testFakeFSOpenFile(t *testing.T, fs Filesystem) {
613 fd, err := fs.OpenFile("foobar", os.O_RDONLY, 0o664)
614 if err == nil {
615 fd.Close()
616 t.Fatalf("got no error opening a non-existing file")
617 }
618
619 fd, err = fs.OpenFile("foobar", os.O_RDWR|os.O_CREATE, 0o664)
620 if err != nil {
621 t.Fatal(err)
622 }
623 fd.Close()
624
625 fd, err = fs.OpenFile("foobar", os.O_RDWR|os.O_CREATE|os.O_EXCL, 0o664)
626 if err == nil {
627 fd.Close()
628 t.Fatalf("created an existing file while told not to")
629 }
630
631 fd, err = fs.OpenFile("foobar", os.O_RDWR|os.O_CREATE, 0o664)
632 if err != nil {
633 t.Fatal(err)
634 }
635 fd.Close()
636
637 fd, err = fs.OpenFile("foobar", os.O_RDWR, 0o664)
638 if err != nil {
639 t.Fatal(err)
640 }
641 fd.Close()
642}
643
644func testFakeFSOpenFileInsens(t *testing.T, fs Filesystem) {
645 fd, err := fs.OpenFile("FooBar", os.O_RDONLY, 0o664)

Callers

nothing calls this directly

Calls 3

FatalMethod · 0.80
OpenFileMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected