blob: 7fca3ecca7ace134bec88db92343998a5e4a8c4f [file] [log] [blame]
Ash Wilsonfd566482014-09-23 15:47:35 -04001// +build acceptance
2
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
20 pager := images.List(client)
21 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}