예제 #1
0
func TestListResourceTypes(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	os.HandleListTypesSuccessfully(t, os.ListTypesOutput)

	count := 0
	err := ListTypes(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
		count++
		actual, err := os.ExtractResourceTypes(page)
		th.AssertNoErr(t, err)

		th.CheckDeepEquals(t, os.ListTypesExpected, actual)

		return true, nil
	})
	th.AssertNoErr(t, err)
	th.CheckEquals(t, 1, count)
}
예제 #2
0
func (command *commandListTypes) Execute(resource *handler.Resource) {
	pager := stackresources.ListTypes(command.Ctx.ServiceClient)
	pages, err := pager.AllPages()
	if err != nil {
		resource.Err = err
		return
	}
	resourceTypes, err := osStackResources.ExtractResourceTypes(pages)
	if err != nil {
		resource.Err = err
		return
	}
	sort.Sort(resourceTypes)
	result := make([]map[string]interface{}, len(resourceTypes))
	for i, resourceType := range resourceTypes {
		result[i] = make(map[string]interface{})
		result[i]["ResourceType"] = resourceType
	}
	resource.Result = result
}