blob: 99f3c36352f39eec5c24ffa03b21c2e905c9939a [file] [log] [blame]
Joe Topjian71b85bd2017-03-09 18:55:36 -07001package testing
2
3import (
4 "testing"
5
Krzysztof Szukiełojć24a29ce2017-05-07 14:24:02 +02006 "gerrit.mcp.mirantis.net/debian/gophercloud.git/openstack/dns/v2/zones"
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"
Joe Topjian71b85bd2017-03-09 18:55:36 -070010)
11
12func TestList(t *testing.T) {
13 th.SetupHTTP()
14 defer th.TeardownHTTP()
15 HandleListSuccessfully(t)
16
17 count := 0
18 err := zones.List(client.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
19 count++
20 actual, err := zones.ExtractZones(page)
21 th.AssertNoErr(t, err)
22 th.CheckDeepEquals(t, ExpectedZonesSlice, actual)
23
24 return true, nil
25 })
26 th.AssertNoErr(t, err)
27 th.CheckEquals(t, 1, count)
28}
29
30func TestListAllPages(t *testing.T) {
31 th.SetupHTTP()
32 defer th.TeardownHTTP()
33 HandleListSuccessfully(t)
34
35 allPages, err := zones.List(client.ServiceClient(), nil).AllPages()
36 th.AssertNoErr(t, err)
37 allZones, err := zones.ExtractZones(allPages)
38 th.AssertNoErr(t, err)
39 th.CheckEquals(t, 2, len(allZones))
40}
41
42func TestGet(t *testing.T) {
43 th.SetupHTTP()
44 defer th.TeardownHTTP()
45 HandleGetSuccessfully(t)
46
47 actual, err := zones.Get(client.ServiceClient(), "a86dba58-0043-4cc6-a1bb-69d5e86f3ca3").Extract()
48 th.AssertNoErr(t, err)
49 th.CheckDeepEquals(t, &FirstZone, actual)
50}