21891: Test copier with a large collection.
[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         "context"
9         "errors"
10
11         "git.arvados.org/arvados.git/sdk/go/arvados"
12         "git.arvados.org/arvados.git/sdk/go/arvadostest"
13         check "gopkg.in/check.v1"
14 )
15
16 var _ = check.Suite(&GroupSuite{})
17
18 type GroupSuite struct {
19         FederationSuite
20 }
21
22 func makeConn() (*Conn, *arvadostest.APIStub, *arvadostest.APIStub) {
23         localAPIstub := &arvadostest.APIStub{Error: errors.New("No result")}
24         remoteAPIstub := &arvadostest.APIStub{Error: errors.New("No result")}
25         return &Conn{context.Background(), &arvados.Cluster{ClusterID: "local"}, localAPIstub, map[string]backend{"zzzzz": remoteAPIstub}}, localAPIstub, remoteAPIstub
26 }
27
28 func (s *UserSuite) TestGroupContents(c *check.C) {
29         conn, localAPIstub, remoteAPIstub := makeConn()
30         conn.GroupContents(s.ctx, arvados.GroupContentsOptions{UUID: "local-tpzed-xurymjxw79nv3jz"})
31         c.Check(len(localAPIstub.Calls(nil)), check.Equals, 1)
32         c.Check(len(remoteAPIstub.Calls(nil)), check.Equals, 0)
33
34         conn, localAPIstub, remoteAPIstub = makeConn()
35         conn.GroupContents(s.ctx, arvados.GroupContentsOptions{UUID: "zzzzz-tpzed-xurymjxw79nv3jz"})
36         c.Check(len(localAPIstub.Calls(nil)), check.Equals, 1)
37         c.Check(len(remoteAPIstub.Calls(nil)), check.Equals, 0)
38
39         conn, localAPIstub, remoteAPIstub = makeConn()
40         conn.GroupContents(s.ctx, arvados.GroupContentsOptions{UUID: "local-j7d0g-xurymjxw79nv3jz"})
41         c.Check(len(localAPIstub.Calls(nil)), check.Equals, 1)
42         c.Check(len(remoteAPIstub.Calls(nil)), check.Equals, 0)
43
44         conn, localAPIstub, remoteAPIstub = makeConn()
45         conn.GroupContents(s.ctx, arvados.GroupContentsOptions{UUID: "zzzzz-j7d0g-xurymjxw79nv3jz"})
46         c.Check(len(localAPIstub.Calls(nil)), check.Equals, 0)
47         c.Check(len(remoteAPIstub.Calls(nil)), check.Equals, 1)
48
49         conn, localAPIstub, remoteAPIstub = makeConn()
50         conn.GroupContents(s.ctx, arvados.GroupContentsOptions{UUID: "zzzzz-tpzed-xurymjxw79nv3jz", ClusterID: "zzzzz"})
51         c.Check(len(localAPIstub.Calls(nil)), check.Equals, 0)
52         c.Check(len(remoteAPIstub.Calls(nil)), check.Equals, 1)
53 }