Rackspace Auto Scale: Add policies Create()
diff --git a/rackspace/autoscale/v1/policies/requests_test.go b/rackspace/autoscale/v1/policies/requests_test.go
index ef2a285..bf49816 100644
--- a/rackspace/autoscale/v1/policies/requests_test.go
+++ b/rackspace/autoscale/v1/policies/requests_test.go
@@ -8,6 +8,10 @@
"github.com/rackspace/gophercloud/testhelper/client"
)
+const (
+ groupID = "10eb3219-1b12-4b34-b1e4-e10ee4f24c65"
+)
+
func TestList(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
@@ -42,3 +46,51 @@
t.Errorf("Expected 1 page, saw %d", pages)
}
}
+
+func TestCreate(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandlePolicyCreateSuccessfully(t)
+
+ client := client.ServiceClient()
+ opts := CreateOpts{
+ {
+ Name: "webhook policy",
+ Type: Webhook,
+ Cooldown: 300,
+ Adjustment: Adjustment{
+ Type: ChangePercent,
+ Value: 3.3,
+ },
+ },
+ {
+ Name: "one time",
+ Type: Schedule,
+ Adjustment: Adjustment{
+ Type: Change,
+ Value: -1,
+ },
+ Args: map[string]interface{}{
+ "at": "2020-04-01T23:00:00.000Z",
+ },
+ },
+ {
+ Name: "sunday afternoon",
+ Type: Schedule,
+ Adjustment: Adjustment{
+ Type: DesiredCapacity,
+ Value: 2,
+ },
+ Args: map[string]interface{}{
+ "cron": "59 15 * * 0",
+ },
+ },
+ }
+
+ policies, err := Create(client, groupID, opts).Extract()
+
+ th.AssertNoErr(t, err)
+ th.CheckDeepEquals(t, WebhookPolicy, policies[0])
+ th.CheckDeepEquals(t, OneTimePolicy, policies[1])
+ th.CheckDeepEquals(t, SundayAfternoonPolicy, policies[2])
+}