Jon Perritt | b5c7812 | 2014-10-15 20:44:39 -0500 | [diff] [blame] | 1 | package cdncontainers |
Jon Perritt | 0ba5a56 | 2014-10-15 23:23:12 -0500 | [diff] [blame] | 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers" |
| 7 | "github.com/rackspace/gophercloud/pagination" |
| 8 | th "github.com/rackspace/gophercloud/testhelper" |
| 9 | fake "github.com/rackspace/gophercloud/testhelper/client" |
| 10 | ) |
| 11 | |
| 12 | func TestListCDNContainers(t *testing.T) { |
| 13 | th.SetupHTTP() |
| 14 | defer th.TeardownHTTP() |
| 15 | os.HandleListContainerNamesSuccessfully(t) |
| 16 | |
| 17 | count := 0 |
| 18 | err := List(fake.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) { |
| 19 | count++ |
| 20 | actual, err := ExtractNames(page) |
| 21 | th.AssertNoErr(t, err) |
| 22 | |
| 23 | th.CheckDeepEquals(t, os.ExpectedListNames, actual) |
| 24 | |
| 25 | return true, nil |
| 26 | }) |
| 27 | th.AssertNoErr(t, err) |
| 28 | th.CheckEquals(t, count, 1) |
| 29 | } |
| 30 | |
| 31 | func TestGetCDNContainer(t *testing.T) { |
| 32 | th.SetupHTTP() |
| 33 | defer th.TeardownHTTP() |
| 34 | os.HandleGetContainerSuccessfully(t) |
| 35 | |
| 36 | _, err := Get(fake.ServiceClient(), "testContainer").ExtractMetadata() |
| 37 | th.CheckNoErr(t, err) |
| 38 | |
| 39 | } |
| 40 | |
| 41 | func TestUpdateCDNContainer(t *testing.T) { |
| 42 | th.SetupHTTP() |
| 43 | defer th.TeardownHTTP() |
| 44 | os.HandleUpdateContainerSuccessfully(t) |
| 45 | |
| 46 | options := &UpdateOpts{TTL: 3600} |
Jon Perritt | 260e088 | 2014-10-20 23:31:23 -0500 | [diff] [blame] | 47 | res := Update(fake.ServiceClient(), "testContainer", options) |
| 48 | th.CheckNoErr(t, res.Err) |
Jon Perritt | 0ba5a56 | 2014-10-15 23:23:12 -0500 | [diff] [blame] | 49 | |
| 50 | } |