blob: 98412273f3d69ff9c443f512078b7ce192edde77 [file] [log] [blame]
Jamie Hannaford7afb7af2014-11-04 13:32:20 +01001package monitors
2
3import (
4 "testing"
5
6 th "github.com/rackspace/gophercloud/testhelper"
7 "github.com/rackspace/gophercloud/testhelper/client"
8)
9
10const lbID = 12345
11
12func TestUpdateCONNECT(t *testing.T) {
13 th.SetupHTTP()
14 defer th.TeardownHTTP()
15
16 mockUpdateConnectResponse(t, lbID)
17
18 opts := UpdateConnectMonitorOpts{
19 AttemptLimit: 3,
20 Delay: 10,
21 Timeout: 10,
22 }
23
24 err := Update(client.ServiceClient(), lbID, opts).ExtractErr()
25 th.AssertNoErr(t, err)
26}
27
28func TestUpdateHTTP(t *testing.T) {
29 th.SetupHTTP()
30 defer th.TeardownHTTP()
31
32 mockUpdateHTTPResponse(t, lbID)
33
34 opts := UpdateHTTPMonitorOpts{
35 AttemptLimit: 3,
36 Delay: 10,
37 Timeout: 10,
38 BodyRegex: "{regex}",
39 Path: "/foo",
40 StatusRegex: "200",
41 Type: HTTPS,
42 }
43
44 err := Update(client.ServiceClient(), lbID, opts).ExtractErr()
45 th.AssertNoErr(t, err)
46}
Jamie Hannafordc9a4d892014-11-04 14:01:56 +010047
48func TestGet(t *testing.T) {
49 th.SetupHTTP()
50 defer th.TeardownHTTP()
51
52 mockGetResponse(t, lbID)
53
54 m, err := Get(client.ServiceClient(), lbID).Extract()
55 th.AssertNoErr(t, err)
56
57 expected := &Monitor{
58 Type: CONNECT,
59 Delay: 10,
60 Timeout: 10,
61 AttemptLimit: 3,
62 }
63
64 th.AssertDeepEquals(t, expected, m)
65}