blob: ceab22fa76decbb773487cad994d7c77140862f4 [file] [log] [blame]
Jamie Hannaford2d480372014-10-22 10:47:09 +02001// +build acceptance compute images
Ash Wilsonfd566482014-09-23 15:47:35 -04002
3package v2
4
5import (
6 "testing"
7
8 "github.com/rackspace/gophercloud/openstack/compute/v2/images"
9 "github.com/rackspace/gophercloud/pagination"
10)
11
12func TestListImages(t *testing.T) {
13 client, err := newClient()
14 if err != nil {
15 t.Fatalf("Unable to create a compute: client: %v", err)
16 }
17
18 t.Logf("ID\tRegion\tName\tStatus\tCreated")
19
Jon Perrittef168e62014-10-08 11:14:05 -050020 pager := images.ListDetail(client, nil)
Ash Wilsonfd566482014-09-23 15:47:35 -040021 count, pages := 0, 0
22 pager.EachPage(func(page pagination.Page) (bool, error) {
23 pages++
24 images, err := images.ExtractImages(page)
25 if err != nil {
26 return false, err
27 }
28
29 for _, i := range images {
30 t.Logf("%s\t%s\t%s\t%s", i.ID, i.Name, i.Status, i.Created)
31 }
32
33 return true, nil
34 })
35
36 t.Logf("--------\n%d images listed on %d pages.", count, pages)
37}