1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
11 "git.curoverse.com/arvados.git/sdk/go/arvadostest"
12 check "gopkg.in/check.v1"
15 var _ = check.Suite(&SiteFSSuite{})
17 type SiteFSSuite struct {
23 func (s *SiteFSSuite) SetUpTest(c *check.C) {
25 APIHost: os.Getenv("ARVADOS_API_HOST"),
26 AuthToken: arvadostest.ActiveToken,
29 s.kc = &keepClientStub{
30 blocks: map[string][]byte{
31 "3858f62230ac3c915f300c664312c63f": []byte("foobar"),
33 s.fs = s.client.SiteFileSystem(s.kc)
36 func (s *SiteFSSuite) TestHttpFileSystemInterface(c *check.C) {
37 _, ok := s.fs.(http.FileSystem)
38 c.Check(ok, check.Equals, true)
41 func (s *SiteFSSuite) TestByIDEmpty(c *check.C) {
42 f, err := s.fs.Open("/by_id")
43 c.Assert(err, check.IsNil)
44 fis, err := f.Readdir(-1)
45 c.Check(len(fis), check.Equals, 0)
48 func (s *SiteFSSuite) TestByUUID(c *check.C) {
49 f, err := s.fs.Open("/by_id")
50 c.Assert(err, check.IsNil)
51 fis, err := f.Readdir(-1)
52 c.Check(err, check.IsNil)
53 c.Check(len(fis), check.Equals, 0)
55 err = s.fs.Mkdir("/by_id/"+arvadostest.FooCollection, 0755)
56 c.Check(err, check.Equals, os.ErrExist)
58 f, err = s.fs.Open("/by_id/" + arvadostest.NonexistentCollection)
59 c.Assert(err, check.Equals, os.ErrNotExist)
61 f, err = s.fs.Open("/by_id/" + arvadostest.FooCollection)
62 c.Assert(err, check.IsNil)
63 fis, err = f.Readdir(-1)
65 for _, fi := range fis {
66 names = append(names, fi.Name())
68 c.Check(names, check.DeepEquals, []string{"foo"})
70 _, err = s.fs.OpenFile("/by_id/"+arvadostest.NonexistentCollection, os.O_RDWR|os.O_CREATE, 0755)
71 c.Check(err, check.Equals, ErrInvalidOperation)
72 err = s.fs.Rename("/by_id/"+arvadostest.FooCollection, "/by_id/beep")
73 c.Check(err, check.Equals, ErrInvalidArgument)
74 err = s.fs.Rename("/by_id/"+arvadostest.FooCollection+"/foo", "/by_id/beep")
75 c.Check(err, check.Equals, ErrInvalidArgument)
76 _, err = s.fs.Stat("/by_id/beep")
77 c.Check(err, check.Equals, os.ErrNotExist)
78 err = s.fs.Rename("/by_id/"+arvadostest.FooCollection+"/foo", "/by_id/"+arvadostest.FooCollection+"/bar")
79 c.Check(err, check.IsNil)
81 err = s.fs.Rename("/by_id", "/beep")
82 c.Check(err, check.Equals, ErrInvalidArgument)