Jamie Hannaford | e514541 | 2014-11-06 12:35:59 +0100 | [diff] [blame] | 1 | package sessions |
| 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 TestEnable(t *testing.T) { |
| 13 | th.SetupHTTP() |
| 14 | defer th.TeardownHTTP() |
| 15 | |
| 16 | mockEnableResponse(t, lbID) |
| 17 | |
| 18 | opts := CreateOpts{Type: HTTPCOOKIE} |
| 19 | err := Enable(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 := &SessionPersistence{Type: HTTPCOOKIE} |
| 33 | th.AssertDeepEquals(t, expected, sp) |
| 34 | } |
| 35 | |
| 36 | func TestDisable(t *testing.T) { |
| 37 | th.SetupHTTP() |
| 38 | defer th.TeardownHTTP() |
| 39 | |
| 40 | mockDisableResponse(t, lbID) |
| 41 | |
| 42 | err := Disable(client.ServiceClient(), lbID).ExtractErr() |
| 43 | th.AssertNoErr(t, err) |
| 44 | } |