Jamie Hannaford | 1ba046f | 2014-11-06 13:21:30 +0100 | [diff] [blame] | 1 | package throttle |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | th "github.com/rackspace/gophercloud/testhelper" |
| 7 | "github.com/rackspace/gophercloud/testhelper/client" |
| 8 | ) |
| 9 | |
| 10 | const lbID = 12345 |
| 11 | |
| 12 | func TestCreate(t *testing.T) { |
| 13 | th.SetupHTTP() |
| 14 | defer th.TeardownHTTP() |
| 15 | |
| 16 | mockCreateResponse(t, lbID) |
| 17 | |
| 18 | opts := CreateOpts{MaxConnections: 200} |
| 19 | err := Create(client.ServiceClient(), lbID, opts).ExtractErr() |
| 20 | th.AssertNoErr(t, err) |
| 21 | } |
| 22 | |
| 23 | func TestGet(t *testing.T) { |
| 24 | th.SetupHTTP() |
| 25 | defer th.TeardownHTTP() |
| 26 | |
| 27 | mockGetResponse(t, lbID) |
| 28 | |
| 29 | sp, err := Get(client.ServiceClient(), lbID).Extract() |
| 30 | th.AssertNoErr(t, err) |
| 31 | |
| 32 | expected := &ConnectionThrottle{MaxConnections: 100} |
| 33 | th.AssertDeepEquals(t, expected, sp) |
| 34 | } |
| 35 | |
| 36 | func TestDelete(t *testing.T) { |
| 37 | th.SetupHTTP() |
| 38 | defer th.TeardownHTTP() |
| 39 | |
| 40 | mockDeleteResponse(t, lbID) |
| 41 | |
| 42 | err := Delete(client.ServiceClient(), lbID).ExtractErr() |
| 43 | th.AssertNoErr(t, err) |
| 44 | } |