fixes for failing unit tests after changes
diff --git a/openstack/orchestration/v1/stackresources/requests.go b/openstack/orchestration/v1/stackresources/requests.go
index f33c170..608ce90 100644
--- a/openstack/orchestration/v1/stackresources/requests.go
+++ b/openstack/orchestration/v1/stackresources/requests.go
@@ -8,7 +8,7 @@
// Find retrieves stack resources for the given stack name.
func Find(c *gophercloud.ServiceClient, stackName string) FindResult {
var r FindResult
- _, res.Err = c.Get(findURL(c, stackName), &res.Body, nil)
+ _, r.Err = c.Get(findURL(c, stackName), &r.Body, nil)
return r
}
diff --git a/openstack/orchestration/v1/stacks/requests.go b/openstack/orchestration/v1/stacks/requests.go
index 47d545e..04c5150 100644
--- a/openstack/orchestration/v1/stacks/requests.go
+++ b/openstack/orchestration/v1/stacks/requests.go
@@ -113,6 +113,9 @@
AdoptStackData string `json:"adopt_stack_data" required:"true"`
// The name of the stack. It must start with an alphabetic character.
Name string `json:"stack_name" required:"true"`
+ // A structure that contains either the template file or url. Call the
+ // associated methods to extract the information relevant to send in a create request.
+ TemplateOpts *Template `json:"-" required:"true"`
// The timeout for stack creation in minutes.
Timeout int `json:"timeout_mins,omitempty"`
// A structure that contains either the template file or url. Call the
@@ -135,23 +138,20 @@
return nil, err
}
+ if err := opts.TemplateOpts.Parse(); err != nil {
+ return nil, err
+ }
+
+ if err := opts.TemplateOpts.getFileContents(opts.TemplateOpts.Parsed, ignoreIfTemplate, true); err != nil {
+ return nil, err
+ }
+ opts.TemplateOpts.fixFileRefs()
+ b["template"] = string(opts.TemplateOpts.Bin)
+
files := make(map[string]string)
-
- /*
- if err := opts.TemplateOpts.Parse(); err != nil {
- return nil, err
- }
-
- if err := opts.TemplateOpts.getFileContents(opts.TemplateOpts.Parsed, ignoreIfTemplate, true); err != nil {
- return nil, err
- }
- opts.TemplateOpts.fixFileRefs()
- b["template"] = string(opts.TemplateOpts.Bin)
-
- for k, v := range opts.TemplateOpts.Files {
- files[k] = v
- }
- */
+ for k, v := range opts.TemplateOpts.Files {
+ files[k] = v
+ }
if opts.EnvironmentOpts != nil {
if err := opts.EnvironmentOpts.Parse(); err != nil {
diff --git a/openstack/orchestration/v1/stacks/requests_test.go b/openstack/orchestration/v1/stacks/requests_test.go
index dc018c1..3a22613 100644
--- a/openstack/orchestration/v1/stacks/requests_test.go
+++ b/openstack/orchestration/v1/stacks/requests_test.go
@@ -6,56 +6,13 @@
"github.com/gophercloud/gophercloud/pagination"
th "github.com/gophercloud/gophercloud/testhelper"
fake "github.com/gophercloud/gophercloud/testhelper/client"
+ "github.com/jrperritt/gophercloud"
)
func TestCreateStack(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleCreateSuccessfully(t, CreateOutput)
-
- createOpts := CreateOpts{
- Name: "stackcreated",
- Timeout: 60,
- Template: `
- {
- "stack_name": "postman_stack",
- "template": {
- "heat_template_version": "2013-05-23",
- "description": "Simple template to test heat commands",
- "parameters": {
- "flavor": {
- "default": "m1.tiny",
- "type": "string"
- }
- },
- "resources": {
- "hello_world": {
- "type":"OS::Nova::Server",
- "properties": {
- "key_name": "heat_key",
- "flavor": {
- "get_param": "flavor"
- },
- "image": "ad091b52-742f-469e-8f3c-fd81cadf0743",
- "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n"
- }
- }
- }
- }
- }`,
- DisableRollback: Disable,
- }
- actual, err := Create(fake.ServiceClient(), createOpts).Extract()
- th.AssertNoErr(t, err)
-
- expected := CreateExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestCreateStackNewTemplateFormat(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- HandleCreateSuccessfully(t, CreateOutput)
template := new(Template)
template.Bin = []byte(`
{
@@ -72,7 +29,7 @@
Name: "stackcreated",
Timeout: 60,
TemplateOpts: template,
- DisableRollback: Disable,
+ DisableRollback: gophercloud.Disabled,
}
actual, err := Create(fake.ServiceClient(), createOpts).Extract()
th.AssertNoErr(t, err)
@@ -85,51 +42,6 @@
th.SetupHTTP()
defer th.TeardownHTTP()
HandleCreateSuccessfully(t, CreateOutput)
-
- adoptOpts := AdoptOpts{
- AdoptStackData: `{environment{parameters{}}}`,
- Name: "stackcreated",
- Timeout: 60,
- Template: `
- {
- "stack_name": "postman_stack",
- "template": {
- "heat_template_version": "2013-05-23",
- "description": "Simple template to test heat commands",
- "parameters": {
- "flavor": {
- "default": "m1.tiny",
- "type": "string"
- }
- },
- "resources": {
- "hello_world": {
- "type":"OS::Nova::Server",
- "properties": {
- "key_name": "heat_key",
- "flavor": {
- "get_param": "flavor"
- },
- "image": "ad091b52-742f-469e-8f3c-fd81cadf0743",
- "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n"
- }
- }
- }
- }
- }`,
- DisableRollback: Disable,
- }
- actual, err := Adopt(fake.ServiceClient(), adoptOpts).Extract()
- th.AssertNoErr(t, err)
-
- expected := CreateExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestAdoptStackNewTemplateFormat(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- HandleCreateSuccessfully(t, CreateOutput)
template := new(Template)
template.Bin = []byte(`
{
@@ -163,7 +75,7 @@
Name: "stackcreated",
Timeout: 60,
TemplateOpts: template,
- DisableRollback: Disable,
+ DisableRollback: gophercloud.Disabled,
}
actual, err := Adopt(fake.ServiceClient(), adoptOpts).Extract()
th.AssertNoErr(t, err)
@@ -208,41 +120,6 @@
defer th.TeardownHTTP()
HandleUpdateSuccessfully(t)
- updateOpts := UpdateOpts{
- Template: `
- {
- "heat_template_version": "2013-05-23",
- "description": "Simple template to test heat commands",
- "parameters": {
- "flavor": {
- "default": "m1.tiny",
- "type": "string"
- }
- },
- "resources": {
- "hello_world": {
- "type":"OS::Nova::Server",
- "properties": {
- "key_name": "heat_key",
- "flavor": {
- "get_param": "flavor"
- },
- "image": "ad091b52-742f-469e-8f3c-fd81cadf0743",
- "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n"
- }
- }
- }
- }`,
- }
- err := Update(fake.ServiceClient(), "gophercloud-test-stack-2", "db6977b2-27aa-4775-9ae7-6213212d4ada", updateOpts).ExtractErr()
- th.AssertNoErr(t, err)
-}
-
-func TestUpdateStackNewTemplateFormat(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- HandleUpdateSuccessfully(t)
-
template := new(Template)
template.Bin = []byte(`
{
@@ -276,50 +153,6 @@
defer th.TeardownHTTP()
HandlePreviewSuccessfully(t, GetOutput)
- previewOpts := PreviewOpts{
- Name: "stackcreated",
- Timeout: 60,
- Template: `
- {
- "stack_name": "postman_stack",
- "template": {
- "heat_template_version": "2013-05-23",
- "description": "Simple template to test heat commands",
- "parameters": {
- "flavor": {
- "default": "m1.tiny",
- "type": "string"
- }
- },
- "resources": {
- "hello_world": {
- "type":"OS::Nova::Server",
- "properties": {
- "key_name": "heat_key",
- "flavor": {
- "get_param": "flavor"
- },
- "image": "ad091b52-742f-469e-8f3c-fd81cadf0743",
- "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n"
- }
- }
- }
- }
- }`,
- DisableRollback: Disable,
- }
- actual, err := Preview(fake.ServiceClient(), previewOpts).Extract()
- th.AssertNoErr(t, err)
-
- expected := PreviewExpected
- th.AssertDeepEquals(t, expected, actual)
-}
-
-func TestPreviewStackNewTemplateFormat(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
- HandlePreviewSuccessfully(t, GetOutput)
-
template := new(Template)
template.Bin = []byte(`
{
@@ -336,7 +169,7 @@
Name: "stackcreated",
Timeout: 60,
TemplateOpts: template,
- DisableRollback: Disable,
+ DisableRollback: gophercloud.Disabled,
}
actual, err := Preview(fake.ServiceClient(), previewOpts).Extract()
th.AssertNoErr(t, err)