func TestListResources(t *testing.T) { th.SetupHTTP() defer th.TeardownHTTP() os.HandleListSuccessfully(t, os.ListOutput) count := 0 err := List(fake.ServiceClient(), "hello_world", "49181cd6-169a-4130-9455-31185bbfc5bf", nil).EachPage(func(page pagination.Page) (bool, error) { count++ actual, err := os.ExtractResources(page) th.AssertNoErr(t, err) th.CheckDeepEquals(t, os.ListExpected, actual) return true, nil }) th.AssertNoErr(t, err) th.CheckEquals(t, count, 1) }
func (command *commandList) Execute(resource *handler.Resource) { params := resource.Params.(*paramsList) opts := params.opts stackName := params.stackName stackID := params.stackID pager := stackresources.List(command.Ctx.ServiceClient, stackName, stackID, opts) pages, err := pager.AllPages() if err != nil { resource.Err = err return } info, err := osStackResources.ExtractResources(pages) if err != nil { resource.Err = err return } result := make([]map[string]interface{}, len(info)) for j, resource := range info { result[j] = structs.Map(&resource) result[j]["UpdatedTime"] = resource.UpdatedTime } resource.Result = result }