Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions acceptance/openstack/rds/v3/rds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ func TestRdsLifecycle(t *testing.T) {
})
th.AssertNoErr(t, err)

t.Log("UpgradeDescription")

newAlias := tools.RandomString("alias-", 8)
_, err = instances.UpgradeDescription(client,
instances.UpgradeDescriptionOpts{
InstanceId: rds.Id,
Alias: &newAlias,
})
th.AssertNoErr(t, err)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add check to verify alias/description like:

	getRdsDesc, err := instances.List(client, instances.ListOpts{
		Id: rds.Id,
	})
	th.AssertNoErr(t, err)
	th.AssertEquals(t, newRds.Instances[0].Alias, newAlias)

t.Log("SetSecurityGroup")

_, err = security.SetSecurityGroup(client, security.SetSecurityGroupOpts{
Expand Down
30 changes: 30 additions & 0 deletions openstack/rds/v3/instances/UpgradeDescription.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package instances

import (
golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
)

type UpgradeDescriptionOpts struct {
InstanceId string `json:"-"`
Alias *string `json:"alias"`
}

func UpgradeDescription(client *golangsdk.ServiceClient, opts UpgradeDescriptionOpts) (*string, error) {
b, err := build.RequestBody(opts, "")
if err != nil {
return nil, err
}

raw, err := client.Put(client.ServiceURL("instances", opts.InstanceId, "alias"), b, nil, &golangsdk.RequestOpts{
OkCodes: []int{200},
})
if err != nil {
return nil, err
}

var res JobId
err = extract.Into(raw.Body, &res)
return &res.JobId, err
}
38 changes: 38 additions & 0 deletions openstack/rds/v3/instances/testing/request_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package testing

import (
"net/http"
"testing"

"github.com/opentelekomcloud/gophertelekomcloud/openstack/rds/v3/instances"
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper"
"github.com/opentelekomcloud/gophertelekomcloud/testhelper/client"
)

func TestUpgradeDescription(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()

instanceID := "5b409baece064984a1b3eef6addae50cin01"
expectedAlias := "alias-test"

th.Mux.HandleFunc("/instances/"+instanceID+"/alias", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")

th.TestJSONRequest(t, r, `
{
"alias": "alias-test"
}
`)

w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
})

_, err := instances.UpgradeDescription(client.ServiceClient(), instances.UpgradeDescriptionOpts{
InstanceId: instanceID,
Alias: &expectedAlias,
})

th.AssertNoErr(t, err)
}
Loading