You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

os_test.go 724B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package osfs
  2. import (
  3. "io/ioutil"
  4. "os"
  5. "path/filepath"
  6. "testing"
  7. . "gopkg.in/check.v1"
  8. "gopkg.in/src-d/go-billy.v4/test"
  9. )
  10. func Test(t *testing.T) { TestingT(t) }
  11. type OSSuite struct {
  12. test.FilesystemSuite
  13. path string
  14. }
  15. var _ = Suite(&OSSuite{})
  16. func (s *OSSuite) SetUpTest(c *C) {
  17. s.path, _ = ioutil.TempDir(os.TempDir(), "go-billy-osfs-test")
  18. s.FilesystemSuite = test.NewFilesystemSuite(New(s.path))
  19. }
  20. func (s *OSSuite) TearDownTest(c *C) {
  21. err := os.RemoveAll(s.path)
  22. c.Assert(err, IsNil)
  23. }
  24. func (s *OSSuite) TestOpenDoesNotCreateDir(c *C) {
  25. _, err := s.FS.Open("dir/non-existent")
  26. c.Assert(err, NotNil)
  27. _, err = os.Stat(filepath.Join(s.path, "dir"))
  28. c.Assert(os.IsNotExist(err), Equals, true)
  29. }