15003: Merge branch 'master' into 15003-preprocess-config
[arvados.git] / sdk / go / arvados / fs_site_test.go
index 26a2212a0771b1c12e5cb7c2825e59b48dd6cfcd..80028dc5985bd46e510c45f102eaf7d2ac518287 100644 (file)
@@ -16,12 +16,16 @@ var _ = check.Suite(&SiteFSSuite{})
 
 type SiteFSSuite struct {
        client *Client
-       fs     FileSystem
+       fs     CustomFileSystem
        kc     keepClient
 }
 
 func (s *SiteFSSuite) SetUpTest(c *check.C) {
-       s.client = NewClientFromEnv()
+       s.client = &Client{
+               APIHost:   os.Getenv("ARVADOS_API_HOST"),
+               AuthToken: arvadostest.ActiveToken,
+               Insecure:  true,
+       }
        s.kc = &keepClientStub{
                blocks: map[string][]byte{
                        "3858f62230ac3c915f300c664312c63f": []byte("foobar"),
@@ -38,10 +42,11 @@ func (s *SiteFSSuite) TestByIDEmpty(c *check.C) {
        f, err := s.fs.Open("/by_id")
        c.Assert(err, check.IsNil)
        fis, err := f.Readdir(-1)
+       c.Check(err, check.IsNil)
        c.Check(len(fis), check.Equals, 0)
 }
 
-func (s *SiteFSSuite) TestByUUID(c *check.C) {
+func (s *SiteFSSuite) TestByUUIDAndPDH(c *check.C) {
        f, err := s.fs.Open("/by_id")
        c.Assert(err, check.IsNil)
        fis, err := f.Readdir(-1)
@@ -54,14 +59,29 @@ func (s *SiteFSSuite) TestByUUID(c *check.C) {
        f, err = s.fs.Open("/by_id/" + arvadostest.NonexistentCollection)
        c.Assert(err, check.Equals, os.ErrNotExist)
 
-       f, err = s.fs.Open("/by_id/" + arvadostest.FooCollection)
+       for _, path := range []string{
+               arvadostest.FooCollection,
+               arvadostest.FooPdh,
+               arvadostest.AProjectUUID + "/" + arvadostest.FooCollectionName,
+       } {
+               f, err = s.fs.Open("/by_id/" + path)
+               c.Assert(err, check.IsNil)
+               fis, err = f.Readdir(-1)
+               var names []string
+               for _, fi := range fis {
+                       names = append(names, fi.Name())
+               }
+               c.Check(names, check.DeepEquals, []string{"foo"})
+       }
+
+       f, err = s.fs.Open("/by_id/" + arvadostest.AProjectUUID + "/A Subproject/baz_file")
        c.Assert(err, check.IsNil)
        fis, err = f.Readdir(-1)
        var names []string
        for _, fi := range fis {
                names = append(names, fi.Name())
        }
-       c.Check(names, check.DeepEquals, []string{"foo"})
+       c.Check(names, check.DeepEquals, []string{"baz"})
 
        _, err = s.fs.OpenFile("/by_id/"+arvadostest.NonexistentCollection, os.O_RDWR|os.O_CREATE, 0755)
        c.Check(err, check.Equals, ErrInvalidOperation)