blob: 2a9b71c3828d57c034c895d54009f6258d76fc84 [file] [log] [blame]
jrperritt3d966162016-06-06 14:08:54 -05001package testing
Ash Wilson9d085a82014-10-03 13:05:03 -04002
3import (
Ash Wilson9d085a82014-10-03 13:05:03 -04004 "testing"
5
jrperritt3d966162016-06-06 14:08:54 -05006 "github.com/gophercloud/gophercloud/openstack/identity/v2/tenants"
Jon Perritt27249f42016-02-18 10:35:59 -06007 "github.com/gophercloud/gophercloud/pagination"
8 th "github.com/gophercloud/gophercloud/testhelper"
9 "github.com/gophercloud/gophercloud/testhelper/client"
Ash Wilson9d085a82014-10-03 13:05:03 -040010)
11
Ash Wilson9d085a82014-10-03 13:05:03 -040012func TestListTenants(t *testing.T) {
13 th.SetupHTTP()
14 defer th.TeardownHTTP()
Ash Wilson55f89b82014-10-10 14:06:30 -040015 HandleListTenantsSuccessfully(t)
Ash Wilson9d085a82014-10-03 13:05:03 -040016
17 count := 0
jrperritt3d966162016-06-06 14:08:54 -050018 err := tenants.List(client.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
Ash Wilson9d085a82014-10-03 13:05:03 -040019 count++
20
jrperritt3d966162016-06-06 14:08:54 -050021 actual, err := tenants.ExtractTenants(page)
Ash Wilson9d085a82014-10-03 13:05:03 -040022 th.AssertNoErr(t, err)
23
Ash Wilson55f89b82014-10-10 14:06:30 -040024 th.CheckDeepEquals(t, ExpectedTenantSlice, actual)
Ash Wilson9d085a82014-10-03 13:05:03 -040025
26 return true, nil
27 })
28 th.AssertNoErr(t, err)
29 th.CheckEquals(t, count, 1)
30}