Ejemplo n.º 1
0
func listUsers(t *testing.T, client *gophercloud.ServiceClient) {
	err := users.List(client).EachPage(func(page pagination.Page) (bool, error) {
		userList, err := users.ExtractUsers(page)
		th.AssertNoErr(t, err)

		for _, user := range userList {
			t.Logf("Listing user: ID [%s] Name [%s] Email [%s] Enabled? [%s]",
				user.ID, user.Name, user.Email, strconv.FormatBool(user.Enabled))
		}

		return true, nil
	})

	th.AssertNoErr(t, err)
}
Ejemplo n.º 2
0
func TestList(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()

	mockListResponse(t)

	count := 0

	err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
		count++
		users, err := os.ExtractUsers(page)

		th.AssertNoErr(t, err)
		th.AssertEquals(t, "u1000", users[0].ID)
		th.AssertEquals(t, "u1001", users[1].ID)

		return true, nil
	})

	th.AssertNoErr(t, err)
	th.AssertEquals(t, 1, count)
}