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.

fs_test.go 964B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package billy_test
  2. import (
  3. "testing"
  4. . "gopkg.in/src-d/go-billy.v4"
  5. "gopkg.in/src-d/go-billy.v4/test"
  6. . "gopkg.in/check.v1"
  7. )
  8. type FSSuite struct{}
  9. func Test(t *testing.T) { TestingT(t) }
  10. var _ = Suite(&FSSuite{})
  11. func (s *FSSuite) TestCapabilities(c *C) {
  12. cases := []struct {
  13. caps Capability
  14. expected bool
  15. }{
  16. {LockCapability, false},
  17. {ReadCapability, true},
  18. {ReadCapability | WriteCapability, true},
  19. {ReadCapability | WriteCapability | ReadAndWriteCapability | TruncateCapability, true},
  20. {ReadCapability | WriteCapability | ReadAndWriteCapability | TruncateCapability | LockCapability, false},
  21. {TruncateCapability | LockCapability, false},
  22. }
  23. // This filesystem supports all capabilities except for LockCapability
  24. fs := new(test.NoLockCapFs)
  25. for _, e := range cases {
  26. c.Assert(CapabilityCheck(fs, e.caps), Equals, e.expected)
  27. }
  28. dummy := new(test.BasicMock)
  29. c.Assert(Capabilities(dummy), Equals, DefaultCapabilities)
  30. }