func (s *StorageBlobSuite) TestListContainersPagination(c *chk.C) { cli := getBlobClient(c) c.Assert(deleteTestContainers(cli), chk.IsNil) const n = 5 const pageSize = 2 // Create test containers created := []string{} for i := 0; i < n; i++ { name := randContainer() c.Assert(cli.CreateContainer(name, ContainerAccessTypePrivate), chk.IsNil) created = append(created, name) } sort.Strings(created) // Defer test container deletions defer func() { var wg sync.WaitGroup for _, cnt := range created { wg.Add(1) go func(name string) { c.Assert(cli.DeleteContainer(name), chk.IsNil) wg.Done() }(cnt) } wg.Wait() }() // Paginate results seen := []string{} marker := "" for { resp, err := cli.ListContainers(ListContainersParameters{ Prefix: testContainerPrefix, MaxResults: pageSize, Marker: marker}) c.Assert(err, chk.IsNil) containers := resp.Containers if len(containers) > pageSize { c.Fatalf("Got a bigger page. Expected: %d, got: %d", pageSize, len(containers)) } for _, c := range containers { seen = append(seen, c.Name) } marker = resp.NextMarker if marker == "" || len(containers) == 0 { break } } c.Assert(seen, chk.DeepEquals, created) }