blob: 5e36c2e4545e06d9bd71bd76d3ebed531aa2700f [file] [log] [blame]
Ash Wilson1532f522014-10-20 18:14:17 -04001// +build acceptance
2
3package v2
4
5import (
6 "testing"
7
8 "github.com/rackspace/gophercloud/pagination"
9 "github.com/rackspace/gophercloud/rackspace/compute/v2/images"
10 th "github.com/rackspace/gophercloud/testhelper"
11)
12
13func TestListImages(t *testing.T) {
14 client, err := newClient()
15 th.AssertNoErr(t, err)
16
17 count := 0
18 err = images.ListDetail(client, nil).EachPage(func(page pagination.Page) (bool, error) {
19 count++
20 t.Logf("-- Page %02d --", count)
21
22 is, err := images.ExtractImages(page)
23 th.AssertNoErr(t, err)
24
25 for i, image := range is {
26 t.Logf("[%02d] id=[%s]", i, image.ID)
27 t.Logf(" name=[%s]", image.Name)
28 t.Logf(" created=[%s]", image.Created)
29 t.Logf(" updated=[%s]", image.Updated)
30 t.Logf(" min disk=[%d]", image.MinDisk)
31 t.Logf(" min RAM=[%d]", image.MinRAM)
32 t.Logf(" progress=[%d]", image.Progress)
33 t.Logf(" status=[%s]", image.Status)
34 }
35
36 return true, nil
37 })
38 th.AssertNoErr(t, err)
39 if count < 1 {
40 t.Errorf("Expected at least one page of images.")
41 }
42}
Ash Wilsoncf392732014-10-20 18:21:04 -040043
44func TestGetImage(t *testing.T) {
45 client, err := newClient()
46 th.AssertNoErr(t, err)
47
48 options, err := optionsFromEnv()
49 th.AssertNoErr(t, err)
50
51 image, err := images.Get(client, options.imageID).Extract()
52 th.AssertNoErr(t, err)
53
54 t.Logf("Requested image:")
55 t.Logf(" id=[%s]", image.ID)
56 t.Logf(" name=[%s]", image.Name)
57 t.Logf(" created=[%s]", image.Created)
58 t.Logf(" updated=[%s]", image.Updated)
59 t.Logf(" min disk=[%d]", image.MinDisk)
60 t.Logf(" min RAM=[%d]", image.MinRAM)
61 t.Logf(" progress=[%d]", image.Progress)
62 t.Logf(" status=[%s]", image.Status)
63}