Keith Byrne | bda4859 | 2016-03-23 11:37:08 +0000 | [diff] [blame^] | 1 | // +build fixtures |
| 2 | |
Jamie Hannaford | af4570f | 2015-02-12 13:33:25 +0100 | [diff] [blame] | 3 | package users |
| 4 | |
Jamie Hannaford | 4a17028 | 2015-02-18 14:16:57 +0100 | [diff] [blame] | 5 | import ( |
| 6 | "fmt" |
| 7 | "testing" |
| 8 | |
| 9 | "github.com/rackspace/gophercloud/testhelper/fixture" |
| 10 | ) |
Jamie Hannaford | af4570f | 2015-02-12 13:33:25 +0100 | [diff] [blame] | 11 | |
Jamie Hannaford | d3a78ef | 2015-02-18 12:17:16 +0100 | [diff] [blame] | 12 | const user1 = ` |
| 13 | {"databases": [{"name": "databaseA"}],"name": "dbuser3"%s} |
| 14 | ` |
| 15 | |
| 16 | const user2 = ` |
| 17 | {"databases": [{"name": "databaseB"},{"name": "databaseC"}],"name": "dbuser4"%s} |
| 18 | ` |
| 19 | |
| 20 | var ( |
Jamie Hannaford | 4a17028 | 2015-02-18 14:16:57 +0100 | [diff] [blame] | 21 | instanceID = "{instanceID}" |
| 22 | _rootURL = "/instances/" + instanceID + "/users" |
| 23 | pUser1 = fmt.Sprintf(user1, `,"password":"secretsecret"`) |
| 24 | pUser2 = fmt.Sprintf(user2, `,"password":"secretsecret"`) |
| 25 | createReq = fmt.Sprintf(`{"users":[%s, %s]}`, pUser1, pUser2) |
| 26 | listResp = fmt.Sprintf(`{"users":[%s, %s]}`, fmt.Sprintf(user1, ""), fmt.Sprintf(user2, "")) |
Jamie Hannaford | af4570f | 2015-02-12 13:33:25 +0100 | [diff] [blame] | 27 | ) |
| 28 | |
Jamie Hannaford | 4a17028 | 2015-02-18 14:16:57 +0100 | [diff] [blame] | 29 | func HandleCreate(t *testing.T) { |
| 30 | fixture.SetupHandler(t, _rootURL, "POST", createReq, "", 202) |
| 31 | } |
| 32 | |
| 33 | func HandleList(t *testing.T) { |
| 34 | fixture.SetupHandler(t, _rootURL, "GET", "", listResp, 200) |
| 35 | } |
| 36 | |
| 37 | func HandleDelete(t *testing.T) { |
| 38 | fixture.SetupHandler(t, _rootURL+"/{userName}", "DELETE", "", "", 202) |
| 39 | } |