Joe Topjian | f61691c | 2016-11-05 12:34:59 -0600 | [diff] [blame] | 1 | package testing |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/gophercloud/gophercloud/openstack/identity/v3/projects" |
| 7 | "github.com/gophercloud/gophercloud/pagination" |
| 8 | th "github.com/gophercloud/gophercloud/testhelper" |
| 9 | "github.com/gophercloud/gophercloud/testhelper/client" |
| 10 | ) |
| 11 | |
| 12 | func TestListProjects(t *testing.T) { |
| 13 | th.SetupHTTP() |
| 14 | defer th.TeardownHTTP() |
| 15 | HandleListProjectsSuccessfully(t) |
| 16 | |
| 17 | count := 0 |
| 18 | err := projects.List(client.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) { |
| 19 | count++ |
| 20 | |
| 21 | actual, err := projects.ExtractProjects(page) |
| 22 | th.AssertNoErr(t, err) |
| 23 | |
| 24 | th.CheckDeepEquals(t, ExpectedProjectSlice, actual) |
| 25 | |
| 26 | return true, nil |
| 27 | }) |
| 28 | th.AssertNoErr(t, err) |
| 29 | th.CheckEquals(t, count, 1) |
| 30 | } |