Merge branch '20522-load-dispatch-priv-key'
[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/keepclient"
13         "github.com/arvados/cgofuse/fuse"
14         check "gopkg.in/check.v1"
15 )
16
17 // Gocheck boilerplate
18 func Test(t *testing.T) {
19         check.TestingT(t)
20 }
21
22 var _ = check.Suite(&FSSuite{})
23
24 type FSSuite struct{}
25
26 func (*FSSuite) TestFuseInterface(c *check.C) {
27         var _ fuse.FileSystemInterface = &keepFS{}
28 }
29
30 func (*FSSuite) TestOpendir(c *check.C) {
31         client := arvados.NewClientFromEnv()
32         ac, err := arvadosclient.New(client)
33         c.Assert(err, check.IsNil)
34         kc, err := keepclient.MakeKeepClient(ac)
35         c.Assert(err, check.IsNil)
36
37         var fs fuse.FileSystemInterface = &keepFS{
38                 Client:     client,
39                 KeepClient: kc,
40         }
41         fs.Init()
42         errc, fh := fs.Opendir("/by_id")
43         c.Check(errc, check.Equals, 0)
44         c.Check(fh, check.Not(check.Equals), uint64(0))
45         c.Check(fh, check.Not(check.Equals), invalidFH)
46         errc, fh = fs.Opendir("/bogus")
47         c.Check(errc, check.Equals, -fuse.ENOENT)
48         c.Check(fh, check.Equals, invalidFH)
49 }