github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/db/v1/users/testing/fixtures.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/huaweicloud/golangsdk/testhelper/fixture" 8 ) 9 10 const user1 = ` 11 {"databases": [{"name": "databaseA"}],"name": "dbuser3"%s} 12 ` 13 14 const user2 = ` 15 {"databases": [{"name": "databaseB"},{"name": "databaseC"}],"name": "dbuser4"%s} 16 ` 17 18 var ( 19 instanceID = "{instanceID}" 20 _rootURL = "/instances/" + instanceID + "/users" 21 pUser1 = fmt.Sprintf(user1, `,"password":"secretsecret"`) 22 pUser2 = fmt.Sprintf(user2, `,"password":"secretsecret"`) 23 createReq = fmt.Sprintf(`{"users":[%s, %s]}`, pUser1, pUser2) 24 listResp = fmt.Sprintf(`{"users":[%s, %s]}`, fmt.Sprintf(user1, ""), fmt.Sprintf(user2, "")) 25 ) 26 27 func HandleCreate(t *testing.T) { 28 fixture.SetupHandler(t, _rootURL, "POST", createReq, "", 202) 29 } 30 31 func HandleList(t *testing.T) { 32 fixture.SetupHandler(t, _rootURL, "GET", "", listResp, 200) 33 } 34 35 func HandleDelete(t *testing.T) { 36 fixture.SetupHandler(t, _rootURL+"/{userName}", "DELETE", "", "", 202) 37 }