~jtv/gwacl/close-body

« back to all changes in this revision

Viewing changes to xmlobjects_test.go

  • Committer: Tarmac
  • Author(s): jtv at canonical
  • Date: 2013-07-17 09:31:36 UTC
  • mfrom: (186.1.2 fix-go-upgrade-breakage)
  • Revision ID: tarmac-20130717093136-40q7vr356atji92h
[r=allenap][bug=][author=jtv] Fix the test failures (but not the horrible crashes) that happen when upgrading from go1.0.2 to go1.1.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
    . "launchpad.net/gocheck"
11
11
    "launchpad.net/gwacl/dedent"
12
12
    "sort"
 
13
    "strings"
13
14
)
14
15
 
15
16
type xmlSuite struct{}
37
38
    expected := fmt.Sprintf(template, config.Hostname, config.Username,
38
39
        config.Password, config.UserData,
39
40
        config.DisableSSHPasswordAuthentication)
40
 
    c.Check(xml, Equals, expected)
 
41
    c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
41
42
}
42
43
 
43
44
func (suite *xmlSuite) TestInputEndpoint(c *C) {
63
64
        endpoint.LocalPort, endpoint.Name, endpoint.Port,
64
65
        endpoint.LoadBalancerProbe.Path, endpoint.LoadBalancerProbe.Port,
65
66
        endpoint.LoadBalancerProbe.Protocol, endpoint.Protocol, endpoint.VIP)
66
 
    c.Check(xml, Equals, expected)
 
67
    c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
67
68
}
68
69
 
69
70
func (suite *xmlSuite) TestOSVirtualHardDisk(c *C) {
81
82
        </OSVirtualHardDisk>`)
82
83
    expected := fmt.Sprintf(template, disk.HostCaching, disk.DiskLabel,
83
84
        disk.DiskName, disk.MediaLink, disk.SourceImageName)
84
 
    c.Check(xml, Equals, expected)
 
85
    c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
85
86
}
86
87
 
87
88
func (suite *xmlSuite) TestConfigurationSetNetworkConfiguration(c *C) {
141
142
        endpoint2.LoadBalancerProbe.Protocol, endpoint2.Protocol,
142
143
        endpoint2.VIP,
143
144
        subnet1, subnet2)
144
 
    c.Check(xml, Equals, expected)
 
145
    c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
145
146
}
146
147
 
147
148
func (suite *xmlSuite) TestRole(c *C) {
170
171
        config.ConfigurationSetType, config.Hostname, config.Username,
171
172
        config.Password, config.UserData,
172
173
        config.DisableSSHPasswordAuthentication, role.RoleSize)
173
 
    c.Check(xml, Equals, expected)
 
174
    c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
174
175
}
175
176
 
176
177
func makePersistentVMRole(rolename string) string {
374
375
    observed, err := role.Serialize()
375
376
 
376
377
    c.Assert(err, IsNil)
377
 
    c.Assert(observed, DeepEquals, expected)
 
378
    c.Assert(strings.TrimSpace(observed), DeepEquals, strings.TrimSpace(expected))
378
379
}
379
380
 
380
381
func (suite *xmlSuite) TestNetworkConfigurationSerialize(c *C) {
477
478
 
478
479
    observed, err := input.Serialize()
479
480
    c.Assert(err, IsNil)
480
 
    c.Assert(observed, Equals, expected)
 
481
    c.Assert(strings.TrimSpace(observed), Equals, strings.TrimSpace(expected))
481
482
}
482
483
 
483
484
func (suite *xmlSuite) TestNetworkConfigurationSerializeMinimal(c *C) {
484
485
    expected := fmt.Sprintf(
485
 
        "\n<NetworkConfiguration xmlns=\"%s\"></NetworkConfiguration>",
 
486
        "<NetworkConfiguration xmlns=\"%s\"></NetworkConfiguration>",
486
487
        XMLNS_NC)
487
488
    input := NetworkConfiguration{XMLNS: XMLNS_NC}
488
489
    observed, err := input.Serialize()
489
490
    c.Assert(err, IsNil)
490
 
    c.Assert(observed, Equals, expected)
 
491
    c.Assert(strings.TrimSpace(observed), Equals, strings.TrimSpace(expected))
491
492
}
492
493
 
493
494
func (suite *xmlSuite) TestNetworkConfigurationSerializeSimpleVirtualNetworkSite(c *C) {
517
518
    }
518
519
    observed, err := input.Serialize()
519
520
    c.Assert(err, IsNil)
520
 
    c.Assert(observed, Equals, expected)
 
521
    c.Assert(strings.TrimSpace(observed), Equals, strings.TrimSpace(expected))
521
522
}
522
523
 
523
524
func (suite *xmlSuite) TestCreateAffinityGroup(c *C) {
538
539
 
539
540
    observed, err := input.Serialize()
540
541
    c.Assert(err, IsNil)
541
 
    c.Assert(observed, Equals, expected)
 
542
    c.Assert(strings.TrimSpace(observed), Equals, strings.TrimSpace(expected))
542
543
}
543
544
 
544
545
func (suite *xmlSuite) TestNewCreateAffinityGroup(c *C) {
568
569
 
569
570
    observed, err := input.Serialize()
570
571
    c.Assert(err, IsNil)
571
 
    c.Assert(observed, Equals, expected)
 
572
    c.Assert(strings.TrimSpace(observed), Equals, strings.TrimSpace(expected))
572
573
}
573
574
 
574
575
func (suite *xmlSuite) TestNewUpdateAffinityGroup(c *C) {
737
738
        config.Username, config.Password, config.UserData,
738
739
        config.DisableSSHPasswordAuthentication, role.RoleSize,
739
740
        deployment.VirtualNetworkName, dns.Name, dns.Address)
740
 
    c.Check(xml, Equals, expected)
 
741
    c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
741
742
}
742
743
 
743
744
// From http://msdn.microsoft.com/en-us/library/windowsazure/ee460804.aspx
1082
1083
    expected := fmt.Sprintf(template, s.ServiceName, s.Label, s.Description,
1083
1084
        s.Location, s.AffinityGroup, s.GeoReplicationEnabled, extProperty.Name,
1084
1085
        extProperty.Value)
1085
 
    c.Assert(xml, Equals, expected)
 
1086
    c.Assert(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
1086
1087
}
1087
1088
 
1088
1089
//
1750
1751
 
1751
1752
    observed, err := input.Serialize()
1752
1753
    c.Assert(err, IsNil)
1753
 
    c.Assert(observed, Equals, expected)
 
1754
    c.Assert(strings.TrimSpace(observed), Equals, strings.TrimSpace(expected))
1754
1755
}
1755
1756
 
1756
1757
func (suite *xmlSuite) TestNewUpdateHostedService(c *C) {
1786
1787
          <Uncommitted>c2Vjb25kLWJhc2U2NC1lbmNvZGVkLWJsb2NrLWlk</Uncommitted>
1787
1788
          <Latest>dGhpcmQtYmFzZTY0LWVuY29kZWQtYmxvY2staWQ=</Latest>
1788
1789
        </BlockList>`)
1789
 
    c.Assert(string(observed), Equals, expected)
 
1790
    c.Assert(strings.TrimSpace(string(observed)), Equals, strings.TrimSpace(expected))
1790
1791
}
1791
1792
 
1792
1793
func (suite *xmlSuite) TestGetBlockListDeserialize(c *C) {
1837
1838
    expectedXML := makeOperationXML("StartRoleOperation")
1838
1839
    xml, err := marshalXML(startRoleOperation)
1839
1840
    c.Assert(err, IsNil)
1840
 
    c.Check(string(xml), Equals, expectedXML)
 
1841
    c.Check(strings.TrimSpace(string(xml)), Equals, strings.TrimSpace(expectedXML))
1841
1842
}
1842
1843
 
1843
1844
func (suite *managementAPISuite) TestRestartRoleOperation(c *C) {
1844
1845
    expectedXML := makeOperationXML("RestartRoleOperation")
1845
1846
    xml, err := marshalXML(restartRoleOperation)
1846
1847
    c.Assert(err, IsNil)
1847
 
    c.Check(string(xml), Equals, expectedXML)
 
1848
    c.Check(strings.TrimSpace(string(xml)), Equals, strings.TrimSpace(expectedXML))
1848
1849
}
1849
1850
 
1850
1851
func (suite *managementAPISuite) TestShutdownRoleOperation(c *C) {
1851
1852
    expectedXML := makeOperationXML("ShutdownRoleOperation")
1852
1853
    xml, err := marshalXML(shutdownRoleOperation)
1853
1854
    c.Assert(err, IsNil)
1854
 
    c.Check(string(xml), Equals, expectedXML)
 
1855
    c.Check(strings.TrimSpace(string(xml)), Equals, strings.TrimSpace(expectedXML))
1855
1856
}
1856
1857
 
1857
1858
// TestOSImageWRTAddOSImage demonstrates the OSImage is a suitable container