import (
"bytes"
"encoding/json"
+ "errors"
"io"
"os"
"path/filepath"
return sc.Client.RequestAndDecode(dst, method, path, body, params)
}
-// TestFilterGroup is a very basic filter group test. It makes sure that a
-// collection and group that match the filter are present, and that a group
-// that does not match the filter is not present.
func (s *SiteFSSuite) TestFilterGroup(c *check.C) {
+ // Make sure that a collection and group that match the filter are present,
+ // and that a group that does not match the filter is not present.
s.fs.MountProject("fg", fixtureThisFilterGroupUUID)
_, err := s.fs.OpenFile("/fg/baz_file", 0, 0)
_, err = s.fs.OpenFile("/fg/A Project", 0, 0)
c.Assert(err, check.Not(check.IsNil))
+
+ // An empty filter means everything that is visible should be returned.
+ s.fs.MountProject("fg2", fixtureAFilterGroupTwoUUID)
+
+ _, err = s.fs.OpenFile("/fg2/baz_file", 0, 0)
+ c.Assert(err, check.IsNil)
+
+ _, err = s.fs.OpenFile("/fg2/A Subproject", 0, 0)
+ c.Assert(err, check.IsNil)
+
+ _, err = s.fs.OpenFile("/fg2/A Project", 0, 0)
+ c.Assert(err, check.IsNil)
+
+ // An 'is_a' 'arvados#collection' filter means only collections should be returned.
+ s.fs.MountProject("fg3", fixtureAFilterGroupThreeUUID)
+
+ _, err = s.fs.OpenFile("/fg3/baz_file", 0, 0)
+ c.Assert(err, check.IsNil)
+
+ _, err = s.fs.OpenFile("/fg3/A Subproject", 0, 0)
+ c.Assert(err, check.Not(check.IsNil))
+
+ // An 'exists' 'arvados#collection' filter means only collections with certain properties should be returned.
+ s.fs.MountProject("fg4", fixtureAFilterGroupFourUUID)
+
+ _, err = s.fs.Stat("/fg4/collection with list property with odd values")
+ c.Assert(err, check.IsNil)
+
+ _, err = s.fs.Stat("/fg4/collection with list property with even values")
+ c.Assert(err, check.IsNil)
+
+ // A 'contains' 'arvados#collection' filter means only collections with certain properties should be returned.
+ s.fs.MountProject("fg5", fixtureAFilterGroupFiveUUID)
+
+ _, err = s.fs.Stat("/fg5/collection with list property with odd values")
+ c.Assert(err, check.IsNil)
+
+ _, err = s.fs.Stat("/fg5/collection with list property with string value")
+ c.Assert(err, check.IsNil)
+
+ _, err = s.fs.Stat("/fg5/collection with prop2 5")
+ c.Assert(err, check.Not(check.IsNil))
+
+ _, err = s.fs.Stat("/fg5/collection with list property with even values")
+ c.Assert(err, check.Not(check.IsNil))
}
func (s *SiteFSSuite) TestCurrentUserHome(c *check.C) {
err = s.client.RequestAndDecode(nil, "DELETE", "arvados/v1/collections/"+oob.UUID, nil, nil)
c.Assert(err, check.IsNil)
+ wf, err = s.fs.OpenFile("/home/A Project/oob/test.txt", os.O_CREATE|os.O_RDWR, 0700)
+ c.Assert(err, check.IsNil)
+ err = wf.Close()
+ c.Check(err, check.IsNil)
+
err = project.Sync()
c.Check(err, check.NotNil) // can't update the deleted collection
_, err = s.fs.Open("/home/A Project/oob")
s.fs.MountProject("home", "")
_, err := s.fs.OpenFile("/home/A Project/newfilename", os.O_CREATE|os.O_RDWR, 0)
- c.Check(err, check.ErrorMatches, "invalid argument")
+ c.Check(err, ErrorIs, ErrInvalidOperation)
err = s.fs.Mkdir("/home/A Project/newdirname", 0)
- c.Check(err, check.ErrorMatches, "invalid argument")
+ c.Check(err, ErrorIs, ErrInvalidOperation)
err = s.fs.Mkdir("/by_id/newdirname", 0)
- c.Check(err, check.ErrorMatches, "invalid argument")
+ c.Check(err, ErrorIs, ErrInvalidOperation)
err = s.fs.Mkdir("/by_id/"+fixtureAProjectUUID+"/newdirname", 0)
- c.Check(err, check.ErrorMatches, "invalid argument")
+ c.Check(err, ErrorIs, ErrInvalidOperation)
_, err = s.fs.OpenFile("/home/A Project", 0, 0)
c.Check(err, check.IsNil)
}
+
+type errorIsChecker struct {
+ *check.CheckerInfo
+}
+
+var ErrorIs check.Checker = errorIsChecker{
+ &check.CheckerInfo{Name: "ErrorIs", Params: []string{"value", "target"}},
+}
+
+func (checker errorIsChecker) Check(params []interface{}, names []string) (result bool, errStr string) {
+ err, ok := params[0].(error)
+ if !ok {
+ return false, ""
+ }
+ target, ok := params[1].(error)
+ if !ok {
+ return false, ""
+ }
+ return errors.Is(err, target), ""
+}