File: fixtures.go

package info (click to toggle)
golang-github-rackspace-gophercloud 1.0.0%2Bgit20161013.1012.e00690e8-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,148 kB
  • ctags: 6,414
  • sloc: sh: 16; makefile: 6
file content (39 lines) | stat: -rw-r--r-- 979 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// +build fixtures

package users

import (
	"fmt"
	"testing"

	"github.com/rackspace/gophercloud/testhelper/fixture"
)

const user1 = `
{"databases": [{"name": "databaseA"}],"name": "dbuser3"%s}
`

const user2 = `
{"databases": [{"name": "databaseB"},{"name": "databaseC"}],"name": "dbuser4"%s}
`

var (
	instanceID = "{instanceID}"
	_rootURL   = "/instances/" + instanceID + "/users"
	pUser1     = fmt.Sprintf(user1, `,"password":"secretsecret"`)
	pUser2     = fmt.Sprintf(user2, `,"password":"secretsecret"`)
	createReq  = fmt.Sprintf(`{"users":[%s, %s]}`, pUser1, pUser2)
	listResp   = fmt.Sprintf(`{"users":[%s, %s]}`, fmt.Sprintf(user1, ""), fmt.Sprintf(user2, ""))
)

func HandleCreate(t *testing.T) {
	fixture.SetupHandler(t, _rootURL, "POST", createReq, "", 202)
}

func HandleList(t *testing.T) {
	fixture.SetupHandler(t, _rootURL, "GET", "", listResp, 200)
}

func HandleDelete(t *testing.T) {
	fixture.SetupHandler(t, _rootURL+"/{userName}", "DELETE", "", "", 202)
}