blob: 867cf96a83f65ba567861ad28f04d83260fffaa1 [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
Krzysztof Szukiełojć24a29ce2017-05-07 14:24:02 +02006 "gerrit.mcp.mirantis.net/debian/gophercloud.git/openstack/identity/v2/tenants"
7 "gerrit.mcp.mirantis.net/debian/gophercloud.git/pagination"
8 th "gerrit.mcp.mirantis.net/debian/gophercloud.git/testhelper"
9 "gerrit.mcp.mirantis.net/debian/gophercloud.git/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}