21910: Update all "Authorization: OAuth2 ..." usage to "Bearer".
[arvados.git] / lib / mount / fs_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package mount
6
7 import (
8         "testing"
9
10         "git.arvados.org/arvados.git/sdk/go/arvados"
11         "git.arvados.org/arvados.git/sdk/go/arvadosclient"
12         "git.arvados.org/arvados.git/sdk/go/ctxlog"
13         "git.arvados.org/arvados.git/sdk/go/keepclient"
14         "github.com/arvados/cgofuse/fuse"
15         check "gopkg.in/check.v1"
16 )
17
18 // Gocheck boilerplate
19 func Test(t *testing.T) {
20         check.TestingT(t)
21 }
22
23 var _ = check.Suite(&FSSuite{})
24
25 type FSSuite struct{}
26
27 func (*FSSuite) TestFuseInterface(c *check.C) {
28         var _ fuse.FileSystemInterface = &keepFS{}
29 }
30
31 func (*FSSuite) TestOpendir(c *check.C) {
32         client := arvados.NewClientFromEnv()
33         ac, err := arvadosclient.New(client)
34         c.Assert(err, check.IsNil)
35         kc, err := keepclient.MakeKeepClient(ac)
36         c.Assert(err, check.IsNil)
37
38         var fs fuse.FileSystemInterface = &keepFS{
39                 Client:     client,
40                 KeepClient: kc,
41                 Logger:     ctxlog.TestLogger(c),
42         }
43         fs.Init()
44         errc, fh := fs.Opendir("/by_id")
45         c.Check(errc, check.Equals, 0)
46         c.Check(fh, check.Not(check.Equals), uint64(0))
47         c.Check(fh, check.Not(check.Equals), invalidFH)
48         errc, fh = fs.Opendir("/bogus")
49         c.Check(errc, check.Equals, -fuse.ENOENT)
50         c.Check(fh, check.Equals, invalidFH)
51 }