Merge branch '17465-pysdk-storage-classes-support'
[arvados.git] / lib / controller / federation / group_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package federation
6
7 import (
8         "errors"
9
10         "git.arvados.org/arvados.git/sdk/go/arvados"
11         "git.arvados.org/arvados.git/sdk/go/arvadostest"
12         check "gopkg.in/check.v1"
13 )
14
15 var _ = check.Suite(&GroupSuite{})
16
17 type GroupSuite struct {
18         FederationSuite
19 }
20
21 func makeConn() (*Conn, *arvadostest.APIStub, *arvadostest.APIStub) {
22         localAPIstub := &arvadostest.APIStub{Error: errors.New("No result")}
23         remoteAPIstub := &arvadostest.APIStub{Error: errors.New("No result")}
24         return &Conn{&arvados.Cluster{ClusterID: "local"}, localAPIstub, map[string]backend{"zzzzz": remoteAPIstub}}, localAPIstub, remoteAPIstub
25 }
26
27 func (s *UserSuite) TestGroupContents(c *check.C) {
28         conn, localAPIstub, remoteAPIstub := makeConn()
29         conn.GroupContents(s.ctx, arvados.GroupContentsOptions{UUID: "local-tpzed-xurymjxw79nv3jz"})
30         c.Check(len(localAPIstub.Calls(nil)), check.Equals, 1)
31         c.Check(len(remoteAPIstub.Calls(nil)), check.Equals, 0)
32
33         conn, localAPIstub, remoteAPIstub = makeConn()
34         conn.GroupContents(s.ctx, arvados.GroupContentsOptions{UUID: "zzzzz-tpzed-xurymjxw79nv3jz"})
35         c.Check(len(localAPIstub.Calls(nil)), check.Equals, 1)
36         c.Check(len(remoteAPIstub.Calls(nil)), check.Equals, 0)
37
38         conn, localAPIstub, remoteAPIstub = makeConn()
39         conn.GroupContents(s.ctx, arvados.GroupContentsOptions{UUID: "local-j7d0g-xurymjxw79nv3jz"})
40         c.Check(len(localAPIstub.Calls(nil)), check.Equals, 1)
41         c.Check(len(remoteAPIstub.Calls(nil)), check.Equals, 0)
42
43         conn, localAPIstub, remoteAPIstub = makeConn()
44         conn.GroupContents(s.ctx, arvados.GroupContentsOptions{UUID: "zzzzz-j7d0g-xurymjxw79nv3jz"})
45         c.Check(len(localAPIstub.Calls(nil)), check.Equals, 0)
46         c.Check(len(remoteAPIstub.Calls(nil)), check.Equals, 1)
47
48         conn, localAPIstub, remoteAPIstub = makeConn()
49         conn.GroupContents(s.ctx, arvados.GroupContentsOptions{UUID: "zzzzz-tpzed-xurymjxw79nv3jz", ClusterID: "zzzzz"})
50         c.Check(len(localAPIstub.Calls(nil)), check.Equals, 0)
51         c.Check(len(remoteAPIstub.Calls(nil)), check.Equals, 1)
52 }