Merge lp:~allenap/gwacl/test-unused-chs-fields into lp:gwacl

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: 120
Merged at revision: 118
Proposed branch: lp:~allenap/gwacl/test-unused-chs-fields
Merge into: lp:gwacl
Prerequisite: lp:~allenap/gwacl/test-unused-osimage-fields
Diff against target: 88 lines (+51/-8)
2 files modified
xmlobjects.go (+10/-8)
xmlobjects_test.go (+41/-0)
To merge this branch: bzr merge lp:~allenap/gwacl/test-unused-chs-fields
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Review via email: mp+170396@code.launchpad.net

Commit message

Test CreateHostedService for use with Create Hosted Service calls.

Previously several fields of CreateHostedService were untested.

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

 review: approve

Wow, I didn't think we'd missed this much testing. Thanks for fixing
(this and the others).
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlHCWcUACgkQWhGlTF8G/HfyoACeL3/ANwke46rdlY4JAsaUzz8I
JNQAoIkvDKEZiY+4FsjxeNCA/R09r81Z
=6ow/
-----END PGP SIGNATURE-----

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'xmlobjects.go'
2--- xmlobjects.go 2013-06-19 16:21:29 +0000
3+++ xmlobjects.go 2013-06-19 16:21:29 +0000
4@@ -308,15 +308,13 @@
5 }
6
7 type CreateHostedService struct {
8- // See http://msdn.microsoft.com/en-us/library/windowsazure/hh264518.aspx
9- XMLNS string `xml:"xmlns,attr"`
10- ServiceName string `xml:"ServiceName"`
11- // Label is base64-encoded.
12- Label string `xml:"Label"`
13- Description string `xml:"Description,omitempty"`
14- AffinityGroup string `xml:"AffinityGroup,omitempty"`
15+ XMLNS string `xml:"xmlns,attr"`
16+ ServiceName string `xml:"ServiceName"`
17+ Label string `xml:"Label"` // base64-encoded
18+ Description string `xml:"Description"`
19 Location string `xml:"Location,omitempty"`
20- ExtendedProperties []ExtendedProperty `xml:"ExtendedProperties>ExtendedProperty,omitempty"`
21+ AffinityGroup string `xml:"AffinityGroup"`
22+ ExtendedProperties []ExtendedProperty `xml:"ExtendedProperties>ExtendedProperty"`
23 }
24
25 func NewCreateHostedServiceWithLocation(serviceName, label, location string) *CreateHostedService {
26@@ -329,6 +327,10 @@
27 }
28 }
29
30+func (s *CreateHostedService) Deserialize(data []byte) error {
31+ return xml.Unmarshal(data, s)
32+}
33+
34 //
35 // Deployment bits
36 //
37
38=== modified file 'xmlobjects_test.go'
39--- xmlobjects_test.go 2013-06-19 16:21:29 +0000
40+++ xmlobjects_test.go 2013-06-19 16:21:29 +0000
41@@ -644,6 +644,47 @@
42 c.Assert(observed.Containers[0].Metadata.Items[0].Name(), Equals, "metadata-name")
43 }
44
45+// TestCreateStorageService demonstrates that CreateHostedService is a
46+// suitable container for the CreateHostedService XML tree that are required
47+// for the Create Hosted Service API call.
48+func (suite *xmlSuite) TestCreateHostedService(c *C) {
49+ // From http://msdn.microsoft.com/en-us/library/windowsazure/gg441304.aspx
50+ input := `
51+ <?xml version="1.0" encoding="utf-8"?>
52+ <CreateHostedService xmlns="http://schemas.microsoft.com/windowsazure">
53+ <ServiceName>service-name</ServiceName>
54+ <Label>base64-encoded-service-label</Label>
55+ <Description>description</Description>
56+ <Location>location</Location>
57+ <AffinityGroup>affinity-group</AffinityGroup>
58+ <ExtendedProperties>
59+ <ExtendedProperty>
60+ <Name>property-name</Name>
61+ <Value>property-value</Value>
62+ </ExtendedProperty>
63+ </ExtendedProperties>
64+ </CreateHostedService>
65+ `
66+ expected := &CreateHostedService{
67+ XMLNS: XMLNS,
68+ ServiceName: "service-name",
69+ Label: "base64-encoded-service-label",
70+ Description: "description",
71+ Location: "location",
72+ AffinityGroup: "affinity-group",
73+ ExtendedProperties: []ExtendedProperty{
74+ {
75+ Name: "property-name",
76+ Value: "property-value",
77+ },
78+ },
79+ }
80+ observed := &CreateHostedService{}
81+ err := observed.Deserialize([]byte(input))
82+ c.Assert(err, IsNil)
83+ c.Assert(observed, DeepEquals, expected)
84+}
85+
86 func (suite *xmlSuite) TestNewCreateHostedServiceWithLocation(c *C) {
87 serviceName := "serviceName"
88 label := "label"

Subscribers

People subscribed via source and target branches

to all changes: