19146: Remove unneeded special case checks, explain the needed one.
[arvados.git] / lib / controller / federation / list_test.go
index ce84378a3cbb79d7a4ae894f966bc627bef2b08d..23671b7fbdd068e042e39a0291b250ae35a70f1f 100644 (file)
@@ -58,7 +58,7 @@ func (cl *collectionLister) CollectionList(ctx context.Context, options arvados.
                if cl.MaxPageSize > 0 && len(resp.Items) >= cl.MaxPageSize {
                        break
                }
-               if options.Limit >= 0 && len(resp.Items) >= options.Limit {
+               if options.Limit >= 0 && int64(len(resp.Items)) >= options.Limit {
                        break
                }
                if cl.matchFilters(c, options.Filters) {
@@ -115,8 +115,8 @@ func (s *CollectionListSuite) SetUpTest(c *check.C) {
 
 type listTrial struct {
        count        string
-       limit        int
-       offset       int
+       limit        int64
+       offset       int64
        order        []string
        filters      []arvados.Filter
        selectfields []string
@@ -300,6 +300,7 @@ func (s *CollectionListSuite) TestCollectionListMultiSiteExtraFilters(c *check.C
 
 func (s *CollectionListSuite) TestCollectionListMultiSiteWithCount(c *check.C) {
        for _, count := range []string{"", "exact"} {
+               s.SetUpTest(c) // Reset backends / call counters
                s.test(c, listTrial{
                        count: count,
                        limit: -1,
@@ -314,12 +315,13 @@ func (s *CollectionListSuite) TestCollectionListMultiSiteWithCount(c *check.C) {
 }
 
 func (s *CollectionListSuite) TestCollectionListMultiSiteWithLimit(c *check.C) {
-       for _, limit := range []int{0, 1, 2} {
+       for _, limit := range []int64{0, 1, 2} {
+               s.SetUpTest(c) // Reset backends / call counters
                s.test(c, listTrial{
                        count: "none",
                        limit: limit,
                        filters: []arvados.Filter{
-                               {"uuid", "in", []string{s.uuids[0][0], s.uuids[1][0]}},
+                               {"uuid", "in", []string{s.uuids[0][0], s.uuids[1][0], s.uuids[2][0]}},
                                {"uuid", "is_a", "teapot"},
                        },
                        expectCalls:  []int{0, 0, 0},
@@ -328,6 +330,22 @@ func (s *CollectionListSuite) TestCollectionListMultiSiteWithLimit(c *check.C) {
        }
 }
 
+func (s *CollectionListSuite) TestCollectionListMultiSiteWithHighLimit(c *check.C) {
+       uuids := []string{s.uuids[0][0], s.uuids[1][0], s.uuids[2][0]}
+       for _, limit := range []int64{3, 4, 1234567890} {
+               s.SetUpTest(c) // Reset backends / call counters
+               s.test(c, listTrial{
+                       count: "none",
+                       limit: limit,
+                       filters: []arvados.Filter{
+                               {"uuid", "in", uuids},
+                       },
+                       expectUUIDs: uuids,
+                       expectCalls: []int{1, 1, 1},
+               })
+       }
+}
+
 func (s *CollectionListSuite) TestCollectionListMultiSiteWithOffset(c *check.C) {
        s.test(c, listTrial{
                count:  "none",