blob: 762b139dfd93e5792629ecd5cdee98e8e6e52094 [file] [log] [blame]
Jamie Hannafordf0cd1652014-11-04 10:54:11 +01001package vips
Jamie Hannaford2841a532014-11-04 11:05:42 +01002
3import (
4 "testing"
5
6 "github.com/rackspace/gophercloud/pagination"
7 th "github.com/rackspace/gophercloud/testhelper"
8 "github.com/rackspace/gophercloud/testhelper/client"
9)
10
11const (
12 lbID = 12345
13 vipID = 67890
14)
15
16func TestList(t *testing.T) {
17 th.SetupHTTP()
18 defer th.TeardownHTTP()
19
20 mockListResponse(t, lbID)
21
22 count := 0
23
24 err := List(client.ServiceClient(), lbID).EachPage(func(page pagination.Page) (bool, error) {
25 count++
26 actual, err := ExtractVIPs(page)
27 th.AssertNoErr(t, err)
28
29 expected := []VIP{
30 VIP{ID: 1000, Address: "206.10.10.210", Type: "PUBLIC"},
31 }
32
33 th.CheckDeepEquals(t, expected, actual)
34
35 return true, nil
36 })
37
38 th.AssertNoErr(t, err)
39 th.AssertEquals(t, 1, count)
40}
Jamie Hannafordf7e8e1a2014-11-04 11:48:46 +010041
42func TestCreate(t *testing.T) {
43 th.SetupHTTP()
44 defer th.TeardownHTTP()
45
46 mockCreateResponse(t, lbID)
47
48 opts := CreateOpts{
49 Type: "PUBLIC",
50 Version: "IPV6",
51 }
52
53 vip, err := Create(client.ServiceClient(), lbID, opts).Extract()
54 th.AssertNoErr(t, err)
55
56 expected := &VIP{
57 Address: "fd24:f480:ce44:91bc:1af2:15ff:0000:0002",
58 ID: 9000134,
59 Type: "PUBLIC",
60 Version: "IPV6",
61 }
62
63 th.CheckDeepEquals(t, expected, vip)
64}