| 610 | } |
| 611 | |
| 612 | func 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 | |
| 644 | func testFakeFSOpenFileInsens(t *testing.T, fs Filesystem) { |
| 645 | fd, err := fs.OpenFile("FooBar", os.O_RDONLY, 0o664) |