func testFlavorsList(t *testing.T, client *gophercloud.ServiceClient) string { var id string err := flavors.List(client).EachPage(func(page pagination.Page) (bool, error) { flavorList, err := os.ExtractFlavors(page) th.AssertNoErr(t, err) for _, flavor := range flavorList { t.Logf("Listing flavor: ID [%s] Providers [%+v]", flavor.ID, flavor.Providers) id = flavor.ID } return true, nil }) th.AssertNoErr(t, err) return id }
func TestList(t *testing.T) { th.SetupHTTP() defer th.TeardownHTTP() os.HandleListCDNFlavorsSuccessfully(t) count := 0 err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) { count++ actual, err := os.ExtractFlavors(page) if err != nil { t.Errorf("Failed to extract flavors: %v", err) return false, err } expected := []os.Flavor{ os.Flavor{ ID: "europe", Providers: []os.Provider{ os.Provider{ Provider: "Fastly", Links: []gophercloud.Link{ gophercloud.Link{ Href: "http://www.fastly.com", Rel: "provider_url", }, }, }, }, Links: []gophercloud.Link{ gophercloud.Link{ Href: "https://www.poppycdn.io/v1.0/flavors/europe", Rel: "self", }, }, }, } th.CheckDeepEquals(t, expected, actual) return true, nil }) th.AssertNoErr(t, err) th.CheckEquals(t, 1, count) }