Jon Perritt | 703bfc0 | 2014-10-08 14:35:00 -0500 | [diff] [blame] | 1 | package servers |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame^] | 6 | "github.com/gophercloud/gophercloud" |
| 7 | th "github.com/gophercloud/gophercloud/testhelper" |
Jon Perritt | 703bfc0 | 2014-10-08 14:35:00 -0500 | [diff] [blame] | 8 | ) |
| 9 | |
| 10 | const endpoint = "http://localhost:57909" |
| 11 | |
| 12 | func endpointClient() *gophercloud.ServiceClient { |
| 13 | return &gophercloud.ServiceClient{Endpoint: endpoint} |
| 14 | } |
| 15 | |
| 16 | func TestCreateURL(t *testing.T) { |
| 17 | actual := createURL(endpointClient()) |
| 18 | expected := endpoint + "servers" |
| 19 | th.CheckEquals(t, expected, actual) |
| 20 | } |
| 21 | |
| 22 | func TestListURL(t *testing.T) { |
| 23 | actual := listURL(endpointClient()) |
| 24 | expected := endpoint + "servers" |
| 25 | th.CheckEquals(t, expected, actual) |
| 26 | } |
| 27 | |
| 28 | func TestListDetailURL(t *testing.T) { |
| 29 | actual := listDetailURL(endpointClient()) |
| 30 | expected := endpoint + "servers/detail" |
| 31 | th.CheckEquals(t, expected, actual) |
| 32 | } |
| 33 | |
| 34 | func TestDeleteURL(t *testing.T) { |
| 35 | actual := deleteURL(endpointClient(), "foo") |
| 36 | expected := endpoint + "servers/foo" |
| 37 | th.CheckEquals(t, expected, actual) |
| 38 | } |
| 39 | |
| 40 | func TestGetURL(t *testing.T) { |
| 41 | actual := getURL(endpointClient(), "foo") |
| 42 | expected := endpoint + "servers/foo" |
| 43 | th.CheckEquals(t, expected, actual) |
| 44 | } |
| 45 | |
| 46 | func TestUpdateURL(t *testing.T) { |
| 47 | actual := updateURL(endpointClient(), "foo") |
| 48 | expected := endpoint + "servers/foo" |
| 49 | th.CheckEquals(t, expected, actual) |
| 50 | } |
| 51 | |
| 52 | func TestActionURL(t *testing.T) { |
| 53 | actual := actionURL(endpointClient(), "foo") |
| 54 | expected := endpoint + "servers/foo/action" |
| 55 | th.CheckEquals(t, expected, actual) |
| 56 | } |
Jon Perritt | cc77da6 | 2014-11-16 13:14:21 -0700 | [diff] [blame] | 57 | |
Jon Perritt | 78c57ce | 2014-11-20 11:07:18 -0700 | [diff] [blame] | 58 | func TestMetadatumURL(t *testing.T) { |
| 59 | actual := metadatumURL(endpointClient(), "foo", "bar") |
Jon Perritt | cc77da6 | 2014-11-16 13:14:21 -0700 | [diff] [blame] | 60 | expected := endpoint + "servers/foo/metadata/bar" |
| 61 | th.CheckEquals(t, expected, actual) |
| 62 | } |
| 63 | |
Jon Perritt | 78c57ce | 2014-11-20 11:07:18 -0700 | [diff] [blame] | 64 | func TestMetadataURL(t *testing.T) { |
| 65 | actual := metadataURL(endpointClient(), "foo") |
Jon Perritt | cc77da6 | 2014-11-16 13:14:21 -0700 | [diff] [blame] | 66 | expected := endpoint + "servers/foo/metadata" |
| 67 | th.CheckEquals(t, expected, actual) |
| 68 | } |